Press button by standing on it

Get help using Construct 2

Post » Mon Apr 01, 2013 6:26 am

Hello! I'm trying to do something like this:


By default, the gate is closed.
When you stand on the button, the gate opens.
If you're not standing on the button, the gate closes.

I've tried doing something like the stomping enemy mechanic, but it does not seen to work (I guess because "on collision with" is different from "stand on").

Any ideas? Thanks in advance.
B
6
Posts: 9
Reputation: 732

Post » Mon Apr 01, 2013 6:43 am

Replace on collision with "is overlapping", and then you can put an else event below to close the gate, hope that helps!
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Mon Apr 01, 2013 1:29 pm

Try that method :)

https://dl.dropbox.com/u/108799982/Capx%20Demos/Buttons.capx
Using R238 for all examples
B
60
S
17
G
6
Posts: 363
Reputation: 9,125

Post » Mon Apr 01, 2013 1:36 pm

here is a tutorial i made for you:

https://www.scirra.com/tutorials/511/activation-tile/page-1
B
10
S
4
G
3
Posts: 53
Reputation: 2,613

Post » Tue Apr 02, 2013 2:41 am

Thank you all for the reply!

@Jayjay: your "is overlapping" idea works better than "in collision", thank you! "Else" worked wonders for this case!

@emoaeden: I only got the stable version of Construct 2 (prefer to work with stable builds), so I can't try your method. Thanks anyway.

@zordork: thank you for the tutorial, it uses the basic principle from Jayjay - the only thing is that, as I specified, the doors should close if the buttons are not pressed. Instead of destroying then, I'm changing the animations (to open/closed). Maybe changing sprites altogether would be easier, not sure.

This is how I did it:
player is overlapping (sprite) - set button animation to "pressed"/ set door animation to "open"

else - set button animation to "default" / set door animation to "closed"


Only problem is if I use a animation (say, the door opening), it loops while the button is pressed - even if the animation is set to "not loop". Which is weird. So, for the time being, it is only working with non-animated sprites/animations with only 1 frame.Guisouro2013-04-02 02:43:12
B
6
Posts: 9
Reputation: 732

Post » Tue Apr 02, 2013 3:34 am

@Guisouro, adding another condition to the top event with System condition "Trigger Once While True" should fix that, same with the Else event.

This way it will only play the animation once until the situation changesJayjay2013-04-02 03:35:17
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Tue Apr 02, 2013 4:28 am

@Jayjay: You mean like this?

(buttonpress = button / Sprite4 = door)

It did not work as expected. The door sprite does not change (stays at the first closed frame) and the button does a little flash (changes to pressed and then goes back) on the moment of the overlap.Guisouro2013-04-02 04:29:51
B
6
Posts: 9
Reputation: 732

Post » Tue Apr 02, 2013 5:05 am

Ah I'm sorry, the trigger once should be a sub-event of each to avoid messing with the Else, and then move the actions for each event down into the sub-event.

So it'd be like this:

[Event 1] [NO ACTIONS]
+[Subevent trigger once] [ACTIONS]
[ELSE] [NO ACTIONS]
+[Subevent trigger once] [ACTIONS]
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Tue Apr 02, 2013 5:43 am

OH, now it works perfectly! Awesome, Jayjay.

Thank you very much!
B
6
Posts: 9
Reputation: 732

Post » Tue Apr 02, 2013 12:49 pm

@Guisouro, glad to help!
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Next

Return to How do I....?

Who is online

Users browsing this forum: michaelverdi and 29 guests