Sub Events not working as expected

Just started using Construct 2? Post your questions here

Post » Sat Aug 20, 2016 7:48 pm

I setup a Menu Button that when clicked, it should toggle the menu layer Visible/Invisible. I thought it would be a relatively simple block, but apparently I've done something wrong.

Menu Button - On Clicked
~[Sub] System - Layer 1 is not Visible > System - Set Layer 1 to Visible
~[Sub] System - Layer 1 is Visible > System - Set Layer 1 to Invisible

What's going wrong? When I click it, it will turn the Menu layer on, but then it won't turn off. The only possibility I can think of, is that the Button itself doesn't persist between layers, even though it appears to and can apparently be clicked. :/

Any solutions would be appreciate.
B
5
S
1
Posts: 31
Reputation: 437

Post » Sat Aug 20, 2016 8:14 pm

Events are read in sequence so in your Events, it sets Layer 1 to Visible, which instantly makes the very next Event valid so it sets it back again.

Either use a variable as a toggle or just use 'Else.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Sat Aug 20, 2016 8:46 pm

Ah, thanks for that! The Else option worked wonderfully.
B
5
S
1
Posts: 31
Reputation: 437


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests