如何划分等级? (cocos2d,box2d,iphone)节省CPU和内存?
所以我要创建大的关卡。但有一个问题:有很多看不见的空间(就像马里奥兄弟一样跳跃和奔跑),这将使用内存+CPU。那么我该如何划分我的级别呢?我在 iPhone 上使用 Box2D+ cocos2d。
有什么想法吗?
也许只是将 visible
属性设置为 NO
?但它仍然在记忆中:(。但是 box2d 物体怎么办?销毁并重新创建它们对于 FPS 来说太重了,因为我内置了不应该重新创建的物理系统。我应该在我想要的地方设置固定点吗要将关卡分开,如果玩家距离关卡的最后部分有 200 像素,则应该预加载它,如果玩家距离关卡的最后部分有 200 像素,那么我会卸载它,因为在物理上会出现问题。关卡开始时它有一个独特的动作,后来如果我销毁并重新创建它,它也会做同样的事情,但我不想要
其他想法。
so I'm going to create large levels. But there's a problem: There's much unseen space (it's a jump'n run like mario bros.) and this will use memory + cpu. so how could I split up my levels? I'm using Box2D+ cocos2d for iphone.
Any ideas?
Mayby just set the visible
property to NO
? But it would be still in the memory :(. But what with the box2d bodies? Destroy and recreate them would be to heavy for the FPS, because I have physics built in which should not be recreated. Should I make fix points where i want to split the level up, than if the player is 200 px away it should preload it. and if the player is 200 px away from the last part of the level I unload it. But there would be the problem with the physics, because on the start of the level it has a unique movement and later if i destroy and recreate it it would do the same. but i don't want that.
other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您以编程方式将关卡分成象限(如网格),并在每个方块接近在游戏中可见时加载它,会怎么样?
What if you split the level up programmatically into quadrants, like a grid, and ,loaded each square as it got closer to becoming visible in the game.