Cocos2D-x - Issues when with using CCFollow

左心房为你撑大大i 提交于 2020-01-13 06:58:08

问题


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


回答1:


СС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




回答2:


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.



来源:https://stackoverflow.com/questions/19503596/cocos2d-x-issues-when-with-using-ccfollow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!