Key press same button

Just started using Construct 2? Post your questions here

Post » Mon Oct 17, 2016 6:17 am

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.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Mon Oct 17, 2016 2:01 pm

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
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
68
S
17
G
8
Posts: 637
Reputation: 9,420

Post » Mon Oct 17, 2016 2:04 pm

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?
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Wed Oct 19, 2016 4:59 am

@randomly. 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.

@chrisinfinger 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 @chrisinfinger 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???
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Wed Oct 19, 2016 1:23 pm

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...
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
68
S
17
G
8
Posts: 637
Reputation: 9,420


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 7 guests