开发者

How to create multiple levels with Cocos2d

开发者 https://www.devze.com 2023-02-22 14:02 出处:网络
I\'m creating a simple puzzle game that uses Cocos2d and Box2d but I\'m struggling to find any documentation on how to organise levels.

I'm creating a simple puzzle game that uses Cocos2d and Box2d but I'm struggling to find any documentation on how to organise levels.

The game is similar to Cut the Rope in structure, it has multiple fixed size levels with changing Box2d assets.

Currently my mainGame.m file contains my HUD and methods for creating obstacles. Would the best answer be to call some sort of .plist file for each level that lists the assets to be created, and their respective position, then use a for loop to reference the method in the mainGame.m file?

Or could I create a level class on a seperate xxxxxx.m file that references the methods in my开发者_运维知识库 mainGame.m?

I apologise if this is vague/hard to understand, I'm very confused at the moment and not sure how to move forward :/


A few possibilities come to mind...

  • Have either a separate CCScene instance for each of your levels or a separate CCLayer for each of your levels.
  • Another possibility is having a custom class which just holds metadata about each level. You than re-create all your level data on a single CCLayer instance from a single game scene. This is what we are doing for Mega Jump.

As painful as it might be I would not get into the fine details of storing metadata for your level in a plist file. Hard code values for any static placement of UI or other components you need to do. Likely your time is better spent refining the game itself. Hopefully some of those ideas are useful to you. Certainly let me know if anything doesn't make sense or if you want me to go in depth into one of those items a bit more.


well... the easiest way will be to use LevelSVG so that you can draw the levels in a SVG graphics editor and import them. If you can pay little price then LevelSVG is great.

0

精彩评论

暂无评论...
验证码 换一张
取 消