Key press same button

0 favourites
  • 6 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • Ok so what id want to do is use the same button for key press in this case a "space bar" And Id like for this button to work for each event it calls for separately not lets loop around all 3 event that call for space press no matter how hard the 2nd condition for them because you held the space bar down for longer then 60th a sec.

    But seriously I just want to press space for every event like i press space once go to a different menu and then space go to a different menu etc and then action.

    apparently it likes to remember what key you press down instead of when you trigger that key down.

    Ive tried Boolean, layer visibility, I've tried varables, im at lost to keep the game from remember the first key stroke to allow teh next key press the user to make a choice.

    such as this do you want to attack or defend

    ok do you want to attack that goblin or that dragon

    and all using a space bar to select the action.

    the thing is i want to attack the dragon not always attacking the goblin.

  • The way I have gotten around this is to use groups. Put each spacebar action in its own group and then enable/disable the group when the button is intended to be used for that group.

    Example:

    Spacebar pressed - do some actions - disable group layout1 - go to layout 2 - enable group layout2

  • Whoah man, your post is really hard to understand.

    I don't really seem to understand what you are trying to achieve.

    I guess you want the Space Bar to act as a button for everything? So that it controls every single aspect of menus?

    If that is the case, I don't see how that would be possible...if there are multiple possibilities for the user to choose from, how is the program supposed to know which one of those the user wants to pick when pressing the Space Bar?

    Could you please clarify your intentions?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Imagine if you want to attack an enemy...you press spacebar on the attack selection. Now you want to select a target to hit. Now you want to pressed spacebar again to initiate an attack at the selected target.

    My problem is that you don't get to choose the selection to choose which enemy to hit. But rather it will alway choose the first enemy to hit rather then wait for a 2nd spacebar pressed. As in it uses the same spacebar press from the first call to teh next without allowing you to select the target.

    I see your example but this isn't layout change but rather a simple attack to select target. Similar to Jrpg style where you would select the attack and then you would choose the target and they would all use the same button. Im just wondering why a trigger event would keep playing even if the trigger should be only played once while true ?

    Should i do spacebar press action move to layer 2 disable group choose action and then activate group choose the enemy ? Ill try it but in the mean time could you answer to why a key press would keep firing its trigger even though it should be only played once ?

    Ok that was it just by making group disable and then reenable was it. Although it is quite puzzling to why group would have any more effect then layer visible/invisible since its the same thing as group toggle???

  • The problem comes in the way construct2 works. It runs eventsheets from top to bottom (more or less) 60 times a second. Even if you set a trigger once condition if it's conditions are true every tick it will keep activating... by putting it in a group and deactivating/reactivating group as it's needed/not needed then construct2 will only run it when it is active.

    I see no reason you couldn't use it in one layout you would just need to put all spacebar events in their own groups and manage when they are open/closed...

  • One way to do this is to create an X timer and every time a button is pressed that timer starts (with 0.1). Among the conditions for pressing this button you set: timer X is running and reverses this action (button i) (so it will look like: timer x is not running).

    So:

    space key pressed + timer x is not in execution + screen object /// perform action 1 + start timer x

    space key pressed + timer x not in execution + object NOT in screen /// perform action 2 + start timer x

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)