Switched position.X of 2 Actors
AppsRacK
Member Posts: 346
Can someone kindly enlighten me on how to accomplished this. It already took me some time trying to figure it out but i have no luck tonight. I've tried searching the demos and forum but i cant find anything.
Im using a prototype actor with rules like this.
>>If pressed & Game.FirstTouch = false
----->> game.firstTouch = true
----->> game.FirstX = self.positionX
>>If Pressed & game.FirstTouch = true
----->> game.SwitchedNow = True
----->> game.SecondX = self.positionX
This is where i get stuck coz all the rules i did with switchedNow = true doesnt work.
Thanks.
Im using a prototype actor with rules like this.
>>If pressed & Game.FirstTouch = false
----->> game.firstTouch = true
----->> game.FirstX = self.positionX
>>If Pressed & game.FirstTouch = true
----->> game.SwitchedNow = True
----->> game.SecondX = self.positionX
This is where i get stuck coz all the rules i did with switchedNow = true doesnt work.
Thanks.
Comments
Try putting the last three lines above in the otherwise section.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
If you're "popping" from one state to the other and back again, it's best to put the second state into the otherwise section. I've just done a little test but a bit differently from you, hoping it's what you're after:
Only 2 game attributes, both integer: FirstX, being the first actor's X pos; and SecondX being the second actor's X. The Rules in the pressed actor (unlocked, i.e an instance, so you can access the other actor's attributes via the Expression Editor):
Rule: When Actor receives event: touch is pressed
------ then this next Rule within the first-------
Rule: When Attribute self.position.X = game.FirstX
Change Attribute: self.Position.X To game.SecondX
Change Attribute: scene.Background.Actor2.Position.X To game.FirstX
----then in this second Rule's Otherwise section:-------
Change Attribute self.position.X = game.FirstX
Change Attribute: scene.Background.Actor2.Position.X To game.SecondX
Hope that helps.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
>>First touch on 1 actor will make it a bit larger from the rest to make it stand out and appear selected.
>>Second touch on the other actor (2nd, 3rd 4th or 5th) will initiate the switched of the 2 actor.
>>Then the next touch will be the same as the first touch again and the cycles goes on.
What im having right now is that it continuously exchanging places on 3rd touch onward.
Thanks gyroscope for some input.