How to detect drag speed?
creativeapps
Member Posts: 1,770
How do I detect drag right to left counts. For example If I drag slowley its display low counts if I drag fast its display higher counts. Is there any demo sample for that?
Comments
http://forums.gamesalad.com/discussion/19481/limit-speed-of-drag
http://forums.gamesalad.com/discussion/45856/getting-the-dragging-speed
To get the speed of the mouse.x (for instance) at the fastest frame-rate of the device you could make three (real) attributes 'currentSpeed', 'oldTime' and 'oldMouseX" then use the following three constrain behaviors:
Constrain Attribute [self.currentSpeed] To: [( game.Mouse.Position.X - self.oldMouseX )/( self.Time - self.oldTime )]
Constrain Attribute [self.oldTime] To: [self.Time]
Constrain Attribute [self.oldMouseX] To: [game.Mouse.Position.X]
There is just (barely) enough processing time between iterations so the time value is different (about a 60th of a second at the fastest).
When mouse button is down
-- Timer - every 0 seconds
---- Change Attribute: [self.SwipeSpeed] To [( self.SwipeSpeed *.96)+(( game.Mouse.Position.X - self.oldX )/( self.Time - self.oldTime )*.04)]
---- Change Attribute [self.oldTime] To: [self.Time]
---- Change Attribute [self.oldMouseX] To: [game.Mouse.Position.X]
Just spotted this, really good stuff !