如何使用 Cocos2d 创建多个关卡
我正在创建一个使用 Cocos2d 和 Box2d 的简单益智游戏,但我很难找到有关如何组织关卡的任何文档。
该游戏在结构上类似于 Cut the Rope,它有多个固定大小的关卡,并且具有不断变化的 Box2d 资源。
目前我的 mainGame.m 文件包含我的 HUD 和创建障碍的方法。最好的答案是为每个级别调用某种 .plist 文件,列出要创建的资产及其各自的位置,然后使用 for 循环引用 mainGame.m 文件中的方法?
或者我可以在单独的 xxxxxx.m 文件上创建一个引用 mainGame.m 中的方法的关卡类吗?
如果这很模糊/难以理解,我很抱歉,我现在很困惑,不知道如何继续前进:/
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 :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想到了几种可能性...
尽管这可能很痛苦,但我不会深入讨论在 plist 文件中存储关卡元数据的细节。用于 UI 或您需要执行的其他组件的任何静态放置的硬代码值。可能你的时间最好花在完善游戏本身上。希望其中一些想法对您有用。当然,如果有任何事情没有意义,或者您希望我更深入地了解其中一项内容,请告诉我。
A few possibilities come to mind...
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.
好吧...最简单的方法是使用 LevelSVG,这样您就可以在 SVG 图形编辑器中绘制关卡并导入它们。如果你能花很少的钱,那么 LevelSVG 就很棒。
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.