One touch based movement left or right
ishanpatel21@gmail.com
Member Posts: 3
Hi, I am new to GameSalad. I want to move a object left or right by one click . When the left mouse click is pressed, the object move to left(100). And when the left mouse click pressed again, object move to right(-100). And it repeat the process left to right, and right to left with same left mouse button pressed every time. If I get some help, I appreciate it !!
Answers
Create an integer attribute (self.click) and then make a rule that says:
When mouse button pressed
Then make another integer attribute (self.speed) and rule that says:
When self.click = 0
Otherwise
Put the self.speed attribute into the move behaviors speed setting. Hopefully this gives you something close to what you are looking for.
Twitter:rondorocket
Web: rondorocket.com
@RondoRocket @ishanpatel21@gmail.com sometime ago in a thread @CodeMonkey advised us to use the mod() function not %. Instead of (self.click+1)%2 use mod(self.click+1,2). I can't remember why maybe he can remind us if he see this.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Thanks @RondoRocket @colander. it works.