move to game.touch.x constantly, is this poss?
Hi
I want an actor to constantly follow my touch left and right.
At te mo, I have it set up just to contrain it's x position to my touch.x position.
This works really well when you are sliding the touch lef tand right, and pretty much looks like I want it to.
My problem is, becuase I am using a constrain, when I don't "slide", I can just tap the screen, and the actor obviously just appears at the touch.
Is there a way to do it so it feels like a constrain, but if I touch away, it moves to the touch fairly quick?
I tried using a move to , saying move to a Y position, and X set to the touch.x. and this works but only once, with or without run to completion set.
The move to works if I wrap it in a timer...I.E.
every 0.01 seconds move to, Y-165, X-Touch.X
but that seems like a rubbish way to do it.
I might be missing something really obvious
Anyone got any thoughts?
Sparky
I want an actor to constantly follow my touch left and right.
At te mo, I have it set up just to contrain it's x position to my touch.x position.
This works really well when you are sliding the touch lef tand right, and pretty much looks like I want it to.
My problem is, becuase I am using a constrain, when I don't "slide", I can just tap the screen, and the actor obviously just appears at the touch.
Is there a way to do it so it feels like a constrain, but if I touch away, it moves to the touch fairly quick?
I tried using a move to , saying move to a Y position, and X set to the touch.x. and this works but only once, with or without run to completion set.
The move to works if I wrap it in a timer...I.E.
every 0.01 seconds move to, Y-165, X-Touch.X
but that seems like a rubbish way to do it.
I might be missing something really obvious
Anyone got any thoughts?
Sparky
Comments
I mean it gets to the x position, and stops... I can then re-touch somewhere else, and it will will move there and stop.
But I want to be able to constantly slide my touch and have the actor follow
Use a move behavior.
Then set the direction to:
vectorToAngle( game.Touch.X - self.Position.X , game.Touch.Y - self.Position.Y )
---------
That should do the trick!
-Gamexcb
Will give that a try
Had a tinker around with the vectortoangle, and got it working pretty much as I had imagined it.
Much love.
closing.