Player sprite graphic warps to 0,0 when moving ParallaxNode


#1

Hello,

I’ve come across a rather interesting issue. Currently I have my scene setup so that I have a ParrallaxNode which has a box2d world some box2d bodies and a player sprite. I am trying to implement camera scrolling with the following code called on the update() in the scene:

target->setPosition(ccpAdd(m_obHalfScreenSize, followedNode->getPosition()));

The target is the ParallaxNode and FollowedNode is the player sprite. When the box2d player sprite moves the camera correctly follows the box but the sprite itself is rendered back at 0,0 until the box2d body sleeps when then it is rendered correctly at the box2d body. If I comment the code above out the sprite stays with the box2d body with no issue (though now I have no scrolling), it’s only when I apply the setPosition to the ParallaxNode is when this weird issues occurs. I initially used a CCFollowNode action but it had a weird display issue where it would draw at 0,0 and overlap it with the correct position, why is why I implemented the custom setPosition. The same issue still occurs just without the rendering overlapping. It should also be noted that the other box2d bodies and sprites do not warp like the player one does.

Anybody have any thoughts or suggestions on how I would go about fixing this?


#2

Update on this, apparently I had added a sprite under a SpriteBatch to the scene instead of the SpriteBatch itself which caused this issue. hopefully this well help somebody from banging their head against the wall for an hour or two :slight_smile: