Swipe does not work with change attribute...?
Lynkk
Member, PRO Posts: 11
I'm doing the tutorial on 'Swipe' from the Cookbook
But instead of displaying a text on a second actor, I'm trying to move it on his X-axis.
So I went to the second actor and I created 2 rules:
1st Rule:
When game.direction = 1 (the game real attribute i created).
Change attribute self.position.x to self.position.x + 25
2nd rule:
When game.direction = 2 (the game real attribute i created).
Change attribute self.position.x to self.position.x - 25
The problem it is working only once. So if i press the screen, and swipe right. The 2nd actor is going to move + 25 pixels... And that's it, it's not going to move anymore.
I did try to change the direction = 0 with a timer but no luck...? Is this normal?
Thanks
Comments
Yes, it's normal. That's how GameSalad rules function. If you have a rule that says When [condition is true], that rule will only trigger when the rule changes from false to true. So let's say game.direction is 0. When it changes to 1, then your 1st rule will run. But if it is already 1 and it changes to 1, the rule won't run again. The condition hasn't changed... it's still true.
A timer could work but I'd suggest putting change attribute game.direction to 0 in the Otherwise section of both of your existing rules.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User