Press button by standing on it

0 favourites
  • 10 posts
From the Asset Store
J-BoB Game Button Sound Pack comes with 300 high-quality sound effects
  • Hello! I'm trying to do something like this:

    <img src="https://dl.dropbox.com/u/56306840/_random/button.png" border="0" />

    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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Replace on collision with "is overlapping", and then you can put an else event below to close the gate, hope that helps!

  • here is a tutorial i made for you:

    scirra.com/tutorials/511/activation-tile/page-1

  • 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.

  • 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 changes

  • Jayjay: You mean like this?

    <img src="https://dl.dropbox.com/u/56306840/_random/triggeronce.png" border="0" />

    (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.

  • 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]

  • OH, now it works perfectly! Awesome, Jayjay.

    Thank you very much!

  • Guisouro, glad to help! <img src="smileys/smiley4.gif" border="0" align="middle" />

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