Constrain actor position relative to touch position?
Hey guys, I totally thought I could figure this out in my head or find a similar project but I cant.
So basically I need a set of rules and attributes to make a an actor follow a touch position relative to the first touch. If that makes sense.
In other words, if I touched the screen 200 pixels to the right and 40 pixels higher than the actor and then dragged my finger, the actor would move relative to it.
Any help is appreciated.
Thanks
Olivier
So basically I need a set of rules and attributes to make a an actor follow a touch position relative to the first touch. If that makes sense.
In other words, if I touched the screen 200 pixels to the right and 40 pixels higher than the actor and then dragged my finger, the actor would move relative to it.
Any help is appreciated.
Thanks
Olivier
Comments
create 2 self real attributes :
offset x .
offset y
in your actor make this:
when mouse button is down -
change self.offsetX to - self.position.X - mouse.position.X
change self.offsetY to - self.position.Y - mouse.position.Y
Constrain self.position.X to mouse.position.X+self.offsetX
Constrain self.position.Y to mouse.position.Y+self.offsetY
I think this should work .
Roy.
Thanks