I need a sprite to move at a constant speed and I figured I could use CCMoveTo for this, however, it takes a duration parameter. Of course, I can figure out what the duration should be by determining the distance between the destination and the starting point and how fast it should be traveling.
However, I wasn’t sure if this already existed with cocos2d. I’ve checked around and the only resources I could find suggested doing as I stated. The thing is, I might as well write my own function that modifies the sprites position:
x += cos(direction) * speed;
y -= sin(direction) * speed;
So I am just wondering if there was a way to use CCMoveTo to move to a point at a constant speed, instead of over a duration.
It’s design by cocos2d-iphone. I think it’s right. Speed * Duration = distance, and then convert distance to coordinate in pixels, the result hard to be an integer.