Search code examples
c++cocos2d-xcocos2d-x-3.0

How to add a sprite that is always on the screen in Cocos2d?


I'm doing a platformer game using cocos2d-x v3 in c++, where the maps are usually very large, the visible screen follows the object through the map.

Let's say I want to show a sprite in the top right corner of the screen and it would be in this position even when the screen is following the object.

Using the object position doesn't do it.

Is there a way to show a sprite or whatever in the screen and it would be in the screen even when the screen is moving?

Ps. I'm super noob in game development


Solution

  • I've managed to do it using a Parallax Node, and using the velocity which the sprite goes to Vec2(0,0), this way it stays always on the same spot in the screen.