When sliding sprite, if sprite disappears off the side, it will wrap around to the opposite side?

a 夏天 提交于 2019-12-04 20:46:31

It is not possible to do with one sprite. But you can have two sprites. In common situation when your sprite is sliding along the screen only one sprite will be visible. But when it reaches the border the second one will be visible too. When the second one will completely enter the screen - remove (or hide) the first one.

The best way to implement this is to create a CCNode subclass that will contain first and second sprite and will swap them if required. In this way all your logic will be very simple. You will just work with one CCNode (subclass) and will not think about swaping sprites - it will be done automatically by your class

EDIT

@interface MyNode : CCNode
{
    CCSprite *sprite1;
    CCSprite *sprite2;
    CCSprite *currentSprite;
    bool isChanging; //indicates that now two sprites are visible
}
@end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!