我如何才能仅检测到按下按钮? 我的代码循环

问题描述

我希望用户能够放置不同的颜色。我想将它设置一次并关闭,但是它会循环。我该如何解决?

我正在使用自己的基于C ++ / OpenGL / GLFW的引擎。有没有一种方法可以检测到按下状态,而不是切换状态?众所周知,CtP_NLstd::coutCtIstd::cinCES只是一个字符串。-

-编辑-

所需的输出是:

Editor: pls new color

your input
your input
your input

我实际上得到了什么:

 Editor: pls new color

your input
your input
your input 

Editor: pls new color

your input
your input
your input 

Editor: pls new color

your input
your input
your input

    etc...

 ps. cant switch to gui window too

if (GetKeyState('B') != 1) {
    #undef BGC
}
if (GetKeyState('U') != 1) {
    #undef GIC
}
if (GetKeyState('B') == 1) {
    #ifdef BGC
        break;
    #else       
    CtP_NL(CES << "Enter new Background color:");
    float ctcolor1 = 0;
    float ctcolor2 = 0;
    float ctcolor3 = 0;
    CtI(ctcolor1);
    CtI(ctcolor2);
    CtI(ctcolor3);
    bgc[0] = ctcolor1;
    bgc[1] = ctcolor2;
    bgc[2] = ctcolor3;
    #define BGC     
    #endif
}
if (GetKeyState('U') == 1) {
    #ifdef GIC
        break;
    #else       
    CtP_NL(CES << "CityEditor: Enter new User Interface color:");
    float ctcolor1 = 0;
    float ctcolor2 = 0;
    float ctcolor3 = 0;
    CtI(ctcolor1);
    CtI(ctcolor2);
    CtI(ctcolor3);
    gic[0] = ctcolor1;
    gic[1] = ctcolor2;
    gic[2] = ctcolor3;
    #define GIC 
    #endif
}
if (GetKeyState('R') == 1) {
    CtP_NL("Reset - CityEDITOR");
    CityGraphics::shutdown();
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)