如何解决我如何才能仅检测到按下按钮? 我的代码循环
我希望用户能够放置不同的颜色。我想将它设置一次并关闭,但是它会循环。我该如何解决?
我正在使用自己的基于C ++ / OpenGL / GLFW的引擎。有没有一种方法可以检测到按下状态,而不是切换状态?众所周知,CtP_NL
是std::cout
,CtI
是std::cin
。 CES
只是一个字符串。-
-编辑-
所需的输出是:
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();
}
解决方法
聊天中的答案:
D O N T U S E M A C R O S 用变量代替(我用布尔,更少的空间)
(通过churill)
***对,因为它甚至没有被编译。到目前为止,您的代码是不错的,只需用适当的if和变量替换宏,它就可以工作。
好的,谢谢
有效***
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。