I've got a problem with CCFollow in Cocos2D-X. I want to follow my a Sprite, which is referred to a Box2D-Body.
When i call
this->runAction(CCFollow::create(playerSprite));
in the init method of my GameLayer, the lower left corner of my usual screen is centered on my device and although the emulator.
May anyone help me with this issue ? :/
Best Regards,
stotheg
ССFollow is often not enough for your own purposes. One way out of this situation is to create your custom ССFollow action or adding the required logic in the game loop.
Please read this article, there's a lot of useful information for your question:
The Four Ways of Implementing a Scrolling View with Cocos2D Explained
It could be that you are instantiating CCFollow before the VisibleBoundsWorldspace of your layer is set to the view width and height (check in a debugger if the VisibleBoundsWorldspace rect has zero width and height).
RunAction(new CCFollow(yourNode, CCRect.Zero));
Shouldn't be in the Layer constructor, somewhere like AddedToScene will work better.