setting rotation of actor when dragging
twinpix
Member Posts: 49
I've got an actor that's an arrow. I have behaviors set so when it is dragged, the arrow points in the direction that the user is dragging. Trouble is, when the user stops dragging the actor, the rotation of the arrow flips back to zero. I want it to stay pointing in the correct direction.
Can anyone please fix this code?
Custom Attributes: OldX, OldY, dragging
Timer: Every .25 seconds:
Change Attribute [self.OldX to self.Position.X]
Change Attribute [self.OldY to self.Position.Y]
When self.dragging is true:
Constrain Attribute [self.Rotation to vectorToAngle(game.Mouse.Position.X - self.OldX, game.Mouse.Position.Y - self.OldY) ]
Thanks in advance!
Can anyone please fix this code?
Custom Attributes: OldX, OldY, dragging
Timer: Every .25 seconds:
Change Attribute [self.OldX to self.Position.X]
Change Attribute [self.OldY to self.Position.Y]
When self.dragging is true:
Constrain Attribute [self.Rotation to vectorToAngle(game.Mouse.Position.X - self.OldX, game.Mouse.Position.Y - self.OldY) ]
Thanks in advance!
Comments
Thanks!
http://gamesalad.com/game/play/84035
RH, I get this flashing of the arrow trying to set itself back to zero rotation sometimes. I'm hoping to change the code so it will remain steady. Any ideas?
I can get rid of the flickering but the arrow rotation isn't as responsive. I'm too ill to take actually change it so it works but to remove the flickering I'd remove the timer and change the method of changing old.X and old.Y