How do I prevent player inputs from cascading in code?

Just started using Construct 2? Post your questions here

Post » Sun Aug 02, 2015 7:00 am

Having trouble limiting player inputs from cascading (not sure if there is a better way to describe this problem)

Example: Two menus. Menu A opens Menu B. When Menu B is open and player hits cancel, the input cascades and closes both Menu B and Menu A.

Example Code:

-If menu B is active and player hits cancel, close menu B and make code for menu A active
-If menu A is active and player hits cancel, close menu A

Flipping order of the code does solve the problem, but if I have blocks of code in different spreadsheets, things become complex. Tried disabling groups of code and 'on/off' variables to no avail. Wondering if you guys have a simple solution that I'm overlooking!
B
5
S
1
Posts: 20
Reputation: 415

Post » Sun Aug 02, 2015 2:49 pm

Have you looked into using functions? Use one function for each menu? and then call them independently.
"Were all mad here. I'm mad, your mad." "How do you know I'm mad?" Asked Alice. "You must be" Said the Cheshire Cat. "Or you wouldn't have come here"-Lewis Carroll: Adventures In Wonderland
B
7
S
2
Posts: 113
Reputation: 1,245

Post » Sun Aug 02, 2015 4:05 pm

This would be one of those places to add an "else" event..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Aug 02, 2015 7:04 pm

"else" is the basic way to do it, but why not just a simple cooldown variable? Whenever you do your menu 'action' just set the cooldown variable to like 0.5 (and subtract dt from it whenever it is over 0). Then another menu option can only be called if cooldown = or less than 0.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Mon Aug 03, 2015 2:30 am

a quick dirty example https://mega.nz/#!fZtyDb7T!Vuzkrzm7gtGA ... 2qUKzHvrw4
hope it helps
Image
B
28
S
11
G
2
Posts: 139
Reputation: 3,299


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests