Cocos2d Side Scrolling Game
Which is the best approach to create a side Scrolling racing game? Should I just move the background or work with开发者_JAVA百科 the camera instead? I read in lots of places that moving the background is the way to go, but how do I handle the other players? Sorry if this is a noob question but I'm a bit confused.
i think the best way is to set a point in your scene called ancher which doesn't move in your screen but and calculate every other position relative to it. the ancher is moving along side every other player but in a controled manner (for example you can set it in the middle of your track along side with player), in this case you only have to move the background according to your ancher and then you calculate the other positions all relative to the ancher. it may look a bit complicated but implementing this is much more easier and bugfrier than any other method.
Bind all your players to your background (make them children). Then no handling will be required at all
If you want lots of customization then make your own methods for moving the background, players, etc.
If you just want simple player following then use:
[self runAction:[CCFollow actionWithTarget:(the player's CCLayer) worldBoundary:the World's Boundaries in CGRect]];
or simpler:
[self runAction:[CCFollow actionWithTarget:(the players CCLayer)]];
精彩评论