touch is pressed issue
kajuto
Member Posts: 314
hi there@!! recently I'm making a button when touch is pressed spawn 3 actor that goes up leaving some space between those 3 spawns actors. But i want when touch is pressed 2nd time goes back to the button position. so far, what i made is that when i touch that button spawns 3 actor goes up (okay) and i pressed again it keep coming out , and i put a timer after 5 second goes to that button position behind it.
Button code:
Rule: touch is pressed
1)spawn actor#1 *back of the actor
2)spawn actor#2 *back of the actor
3)spawn actor#3 *back of the actor
Spawn Actor code:
1) move to x=187 & y=220 relative to scene, speed 500
Timer: after 5 second run to completion, move to x=188 & y=44 relative to scene, speed 500 (that position is where the button is).
2) move to x= 187 & y=156 relative to scene, speed 500
Timer: after 5 second run to completion, move to x=187 & y=44 relative to scene, speed 500 (that position is where the button is).
3) move to x= 187 & y=92 relative to scene, speed 500
Timer: after 5 second run to completion, move to x=187 & y=44 relative to scene, speed 500 (that position is where the button is).
beside that, i want when touch is pressed 2nd time goes back to the button position, NOT when i keep touching it keeps coming out infinite time when i pressed because it keep respawning lol
Thanks in advance!!
Button code:
Rule: touch is pressed
1)spawn actor#1 *back of the actor
2)spawn actor#2 *back of the actor
3)spawn actor#3 *back of the actor
Spawn Actor code:
1) move to x=187 & y=220 relative to scene, speed 500
Timer: after 5 second run to completion, move to x=188 & y=44 relative to scene, speed 500 (that position is where the button is).
2) move to x= 187 & y=156 relative to scene, speed 500
Timer: after 5 second run to completion, move to x=187 & y=44 relative to scene, speed 500 (that position is where the button is).
3) move to x= 187 & y=92 relative to scene, speed 500
Timer: after 5 second run to completion, move to x=187 & y=44 relative to scene, speed 500 (that position is where the button is).
beside that, i want when touch is pressed 2nd time goes back to the button position, NOT when i keep touching it keeps coming out infinite time when i pressed because it keep respawning lol
Thanks in advance!!
Best Answers
-
ORBZ Posts: 1,304Sounds like you need a counter attribute to keep track of each time the button is pressed then make a rule based on the value of the counter attribute.
-
JustMe74 Posts: 542I'm not sure I understand what you're asking.
Are you saying that this is what you want to happen:
1). Press a button, and 3 actors are spawned
2). Those three actors then move to a location
3). After 5 seconds, the three actors move to another location
4). If the user presses the button again, the actors all move back to where the button is located
If that is what you're trying to do, then you could:
1). Create an integer attribute "ButtonPressed" with a default value of 1
2). Create a boolean attribute "MoveBack" with a default value of false
3). Create a rule on the button that says when ButtonPressed is 1 and when Touch is Pressed, spawn the three actors, and change ButtonPressed to 2
4). Create a rule on the button that says when ButtonPressed is 2 and when Touch is Pressed, change MoveBack to true and ButtonPressed to 1
5). Create a rule on the actors that says when MoveBack is true, move them back to the position of the button, and then set MoveBack to False
Hope that helps.
Answers
The integer att "buttonPRessed" with default value of 1, you mean Game att or self. att?same for Boolean att "moveBack" default value.
#3 and #4 i put it in the Spawner actor. For the #5 i put inside the moveObject ,