kestorr Posted August 13, 2014 Share Posted August 13, 2014 Hello there. Im trying to add a constant circular motion to a sprite (with no player interraction, the sprite just moves like that), but not sure how.I have tried angular Velocity but that only rotates the sprite from its center. and not in a radius. How can i do this? Thanks. Link to comment Share on other sites More sharing options...
lewster32 Posted August 13, 2014 Share Posted August 13, 2014 This is usually accomplished via trigonometry: http://jsfiddle.net/lewster32/4sj9n927/ Link to comment Share on other sites More sharing options...
kestorr Posted August 13, 2014 Author Share Posted August 13, 2014 Hey thanks for that example. Link to comment Share on other sites More sharing options...
lewster32 Posted August 13, 2014 Share Posted August 13, 2014 No problem - this is a fantastic article to learn more about this kind of stuff: http://www.smashingmagazine.com/2011/10/04/quick-look-math-animations-javascript/ Be aware that if you want to apply this to a physics-enable sprite, you'll need to set sprite.body.moves = false, which may cause some other problems with physics calculations. You can get a similar circular motion effect by applying this loosely to the body.velocity.x and y properties like in this example: http://jsfiddle.net/lewster32/4sj9n927/2/ Be aware though that this isn't as controllable - I'm afraid my maths skills fall a little short here, but I'm sure someone else could improve this SirSandmann 1 Link to comment Share on other sites More sharing options...
Recommended Posts