How to keep an actor's target from changing with every touch
zincotroid
Member Posts: 6
I'm sure that this is probably something very simple I'm over looking.
I want to spawn an actor when I touch the screen and I want that actor to move to the location I touched. The only problem is that if I touch anywhere else before the actor reaches the original location, it turns and heads for the new touch.
how can I set a touch as a target for one actor that will persist after the next touch?
I want to spawn an actor when I touch the screen and I want that actor to move to the location I touched. The only problem is that if I touch anywhere else before the actor reaches the original location, it turns and heads for the new touch.
how can I set a touch as a target for one actor that will persist after the next touch?
Comments
Have the touch activate a spawn boolean.
game.spawnRequest=false
Rule1: (in an invisible game sensor actor or on the background graphic)
when background is touched:
game.spawnLocX = touch.X
game.spawnLocY = touch.Y
game.spawnRequest = true
Rule2: (on Actor)
when game.spawnRequest = true
spawnActor at game.spawnLocX and Y
My rules are:
On touch shoot to true
get x touch
get y touch
make direction vector to angle
spawn bullet at direction
change shoot to false.
I think this is pretty much what synthesis has outlined above but it doesn' t work for me.
Can anybody help with this?
thanks tsb, much appreciated.
X
Y
2 Rules:
Change self.X to Touch1.X
Change self.Y to Touch1.Y
And then the move rule:
Move To: X=self.X & Y=self.Y
So this will make sure it uses the same coordinates regardless if you touch again or not. Depending on timing you may need to set a game attribute for your touches. Like:
(This goes on your BG actor)
When Pressed change game.X to Touch1.X & game.Y to Touch1.Y
And then under your actor instead of :
Change self.X to Touch1.X
Change self.Y to Touch1.Y
DO:
Change self.X to game.X
Change self.Y to game.Y
Try the first way, but depends on how fast the timing is. See which way suits you.
Hope this helps.