I’m trying to move multiple sprites (images) in an elliptical path such that distance (arc distance) remains uniform.
I have tried
-
Move each sprite angle by angle, however the problem with this is that distance moved while moving unit angle around major axis is different than that while moving unit angle around minor axis – hence different distance moved.
-
Move sprites with just changing x-axis uniformly, however it again moves more around major axis.
So any ideas how to move sprites uniformly without them catching-up/overlapping each other?
Other info:
- it will be called in onMouseMove/onTouchMoved so i guess it shouldn’t
be much CPU intensive. - Although its a general algorithm question but
if it helps I’m using cocos2d-x
So this is what i ended up doing (which solved it for me):
I moved it in equation of circle and increased angle by 1 degree. Calculated x and y using sin/cos(angle) * radius. And to make it into an ellipse I multiplied it by a factor.
Factor was yIntercept/xIntercept.
so it looked like this in end