Simple On/Off Button

0 favourites
  • 7 posts
From the Asset Store
J-BoB Game Button Sound Pack comes with 300 high-quality sound effects
  • I have been trying for a while to create this but I can't get it working.

    This is a Coccoon project so I am using touch.

    I followed this post http://www.scirra.com/forum/game-sound-On-off-button-issue_topic46140.html but this uses mouse events.

    I thought to create a sprite with 2 frames and alternate between frame 0 and 1, I can only get it working one way though - switches to frame 1 but can't switch back to frame 0.

    Any help welcome.

    image upload software

  • Events are processed one after the other, so what you have done is test for a condition, set the frame and music, but the very next event sets them back again.

    There are many ways to deal with this, but the easiest is to just use 'Else'.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you can do 1-variable as a neat way of making it toggle between 1 and 0 with one event:

    + Is in touch   

    buttonMusic1 | set animation frame to music

    system       | set music to 1-music

  • Events are processed one after the other, so what you have done is test for a condition, set the frame and music, but the very next event sets them back again.

    There are many ways to deal with this, but the easiest is to just use 'Else'.

    Yes that's exactly what I wanted to do, set the frame and music then if the user wishes set them back again.

    I can't see how your solution sets the button back - to explain I want frame 0 to show then when the button is pressed frame 1 shows, pressed again frame 0 shows etc. A simple on/off. I have tried every conceivable variant of touch and I can't get it to work.

  • You misunderstand how the events work. The way you have it setup means that the first condition, if set, will 'automatically' trigger the next condition, even without touching it.

  • keepee heh, I usually do that using var * -1, then check if it's -1 or 1. Your way looks prettier though <img src="smileys/smiley17.gif" border="0" align="middle" />

  • andreyin

    sometimes toggling 1 and -1 is useful though, so I'll remember yours too

    yay learning

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