One button with 2 diff. conditions, and actions

0 favourites
  • 4 posts
From the Asset Store
Alot of High Quality Items sound effects for your game!
  • Hi all!

    I'm new here and I would like to ask your help!

    I started a project (a multiplatform game for mobiles and for tablets), and I got the following problem. What I want to do in my game is that after I touch the 'button' sprite the other sprite will be spwaned on the screen and a variable value will be changed to 1, and after a second touch on the same button, the other spite will will disapears and the variable change back to 0. I will use this to a character hold a weapon sprite (spawn into his hands) and change the variable value to 1 from 0, and with the same button I (when variable is 1) can delete the weapon from his hands. The problem is that I won't work if I made 2 event for the same button and adding into them another extra condition ( so 1 event is "if you touch the button and the variable is 0 then..." the orher one is when you touch the same button just the variable will be 1)

    I made a simple capx to represent this. You can dl it form:

    dropbox.com/s/nmmx5madjwfnbqm/touch_test.capx

    For this I have a global variable, default value is 0. I have 2 objects (a red and a yellow square, and I destroy the red one on start of layout). Normaly, I think this event sheet will makes what I want, but when you run it then it seems to me both of the touch events have run down, and ignores the conditions with the variable value..

    Note that, if you disable the destroy action then it works well (ofc exept the destroy), the variable will change. And if you disable the action wich sets the variable to 0 then the destroy action works..

    I'm confused about why only one action can run down in this way. Hope you can help..

    Thanks in advance!

    peterm

  • here is one way to do this

    <img src="https://dl.dropboxusercontent.com/u/143636437/examples%20for%20web/Ashampoo_Snap_2013.12.30_14h44m29s_001.png" border="0" />

  • never noticed the wait 0 you had in - probably not needed ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks RamPackWobble! It works, even without the wait 0.

    Cheers! <img src="smileys/smiley1.gif" border="0" align="middle" />

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