You need to calculate the “distance” between your [start] and [end] points, and then you can calculate the “duration” so that your sprite moves at a constant speed. Sort of,
float speed = 1; // here you define the speed you want to use.
CGPoint start = sprite.position; // here you will get the current position of your sprite. CGPoint end = ccp(pointBoard[x][y].x,pointBoard[x][y].y); float distance = ccpDistance(start, end); // now you have the distance float duration = distance/speed; // here you find the duration required to cover the distance at constant speed
Now you can call the CCMoveTo function and provide the calculated duration above so that your sprite moves at the same speed.
Hope this helps .. !!
source share