Jump to content

Check For Any Key Pressed / Alt Key Mapping


gamecreator
 Share

Recommended Posts

At the title screen, I would like to have the user "Press any key to continue..." I couldn't find a Leadwerks function that does this. I also searched the forums and no luck there either.

 

Possibilities:

 

- Use a Windows-only function like GetKeyboardState though I'd rather not have this be the only thing preventing a Linux deployment

- See if I can incorporate another library like SDL but I doubt the Publisher will play well with it and I'd also rather avoid this

- Somehow check all of the keys one by one with KeyHit. I'm not sure how this would work as far as C code goes besides something going in a loop. For example, is it safe to check for later letters by incrementing on A (A+1, A+2, etc.)?

 

Thoughts?

 

Also, is there any way to not have the Alt button trigger the window menu? Most games let you map this button.

Link to comment
Share on other sites

I made a helper class with a method AnyKeyDown(). I would loop over all the keys or a specific set like enter, space, escape, etc.

The downside to this is that Leadwerks has now marked those checked key as used. So if you would check the

state of a button again in another script, it would return a different value. That why I store the values of every key and use my own functions to check for key down/up.

 

Maybe this has changed though (haven't used in Le in a while).

  • Upvote 1
Link to comment
Share on other sites

I made a helper class with a method AnyKeyDown(). I would loop over all the keys or a specific set like enter, space, escape, etc.

The downside to this is that Leadwerks now has marked those checked key as used. So if you would check the

state of a button again in another script, it would return a different value. That why I store the values of every key and use my own functions to check for key down/up.

 

Maybe this has changed though (haven't used in Le in a while).

 

 

Hi, I Think you just pin pointed one of my major bugs. When i pick up a weapon in my game, it shoots once. So i made like a timer thing were u can shoot only after 1 second of picking it up. Anyway, is there a way around this?

Link to comment
Share on other sites

I'm using C/C++ so Lua limitations are not an issue. I think going the method you suggested is the best, unless someone has a better idea. It's not that bad to do this one by one

 

key[i++]=Key::A;
key[i++]=Key::B;
etc.

 

or if they're incremental

 

(for int i=0; i<26; i++) key[i]=Key::A+i;

 

but not sure how reliable this is.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...