I am a beginner making a 2D game using Cocos2D and I would need assistance with some physics matter which I cannot solve.
I managed to have some planetoids with radial gravity that make a ball rotate around them. Right now, I have the small ball rotating around one planetoid due to this radial gravity and other external forces (no CCActions or similar). The ball is a dynamic physics body whereas the planetoids are static physics bodies.
I also got to have the ball always centered in the middle of the screen while the rest of the world spins around it. Think of it as a camera always being centered on the ball and following it along the planetoids.
In order to achieve this camera effect I detect the rotation angle of the ball with respect to the planetoid it rotates around, and then I set this rotation angle to the node that contains everything (ball, planetoids).
I have a node's hierarchy like this:
CCNode (GameScene): cocos2d scene
a. CCNode (background): scrolling background
b. CCNode (levelNode): container for level elements
- CCPhysicsNode (contains planetoids and ball nodes)
What I rotate is the levelNode. However, this rotation seems to be affecting the ball rotating around the planetoid: it makes the planetoid and the ball tremble/shake a little bit, sometimes too much creating a dizzy effect which I would like to remove completely. I checked by NOT rotating the levelNode and there is no trembling/shaking camera effect.
I do not understand how the rotation of the levelNode could be affecting the physics, since all the levelNode's children keep their positions relative to their parent (that is, the levelNode). The levelNode, even if it rotates, does not change its children's local positions due to the rotation
Could someone provide me with some hints to overcome this issue? I would be very grateful for any assistance.