Cocos2d Side Scrolling Game

What is the best approach to create a scrolling racing game? Should I just move the background or work with the camera? I read in many places that moving the background is the way to go, but how can I handle other players? Sorry if this is a question about noob, but I'm a little confused.

+3
source share
3 answers

I think the best way is to set a point in your scene called ancher, which does not move on your screen, but calculates every other position relative to it. The archer moves along each other player, but is controlled (for example, you can set it in the middle of your track together with the player), in this case you only need to move the background according to your character, and then you calculate other positions relative to the anchor. it may look a little more complicated, but implementing it is much simpler and more complicated than any other method.

+2
source

Bind all your players to the background (make them children). Then no processing is required at all

0
source

If you need a lot of customization, create your own methods for moving the background, players, etc.

If you just need a simple player, use:

[self runAction:[CCFollow actionWithTarget:(the player CCLayer) worldBoundary:the World Boundaries in CGRect]];

or simpler:

[self runAction:[CCFollow actionWithTarget:(the players CCLayer)]];
0
source

Source: https://habr.com/ru/post/1793239/


All Articles