reepblue Posted yesterday at 12:26 AM Posted yesterday at 12:26 AM I've noticed that when using window->KeyHit() if you hold down the key, the function will keep returning true. My solution for this problem is to poll the input events myself but that's not an ideal solution. Hold down the space key in this example and it should rapidly change the panel's colors. //------------------------------------------------------------------------------------------------- // // This example uses the space key to control the color of a panel widget. // //------------------------------------------------------------------------------------------------- #include "Leadwerks.h" using namespace Leadwerks; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create windows auto window = CreateWindow("Leadwerks", 0, 0, 800, 600, displays[0]); //Create user interface auto ui = CreateInterface(window); while (true) { if (window->KeyHit(KEY_SPACE)) { ui->root->SetColor(Random(1.0f), Random(1.0f), Random(1.0f), 1); } const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWCLOSE: return 0; break; } } return 0; } Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon!
Josh Posted yesterday at 12:41 AM Posted yesterday at 12:41 AM When I run this example and hold down the space key the window color only changes once. 1 Quote Let's build cool stuff and have fun.
reepblue Posted yesterday at 12:52 AM Author Posted yesterday at 12:52 AM I'll do more investigating. I'm just recalling a bug I encountered in my project but there was also a quite a bit going on. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon!
Solution Josh Posted 6 hours ago Solution Posted 6 hours ago In our game, there was a problem where a call to window->FlushKeys() was resetting the key down state, making the invetory screen flash on and off. Quote Let's build cool stuff and have fun.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.