CCLayer setRotation update of child positions

CCLayer setRotation update of child positions
0.0 0



I’ve got a mutable array of sprites which get added to a layer.
When i rotate the layer with setRotation the sprites move as expected, but when i read out the position of those sprites from the mutable array in the update fuction, it reads the initial possition the sprites had before the rotation.

Below is how i added the sprite to the layer first and then to the array.


What do i need to do in order to read the new position the sprites got after their layer was rotated?



Yeah the sprites are rotated relative to the parent layer.

You can calculate the new position yourself using code like this:

RotatePoint.x = pOrigin.x + cos(Degrees) * (pPoint.x - pOrigin.x) - sin(Degrees) * (pPoint.y - pOrigin.y);
RotatePoint.y = pOrigin.y + sin(Degrees) * (pPoint.x - pOrigin.x) + cos(Degrees) * (pPoint.y - pOrigin.y);

… I haven’t tried it but it should work.