cocos2d 场景可以只占据设备屏幕的一部分吗?
我正在开发一款 iOS 动作游戏,其中玩家在各个“房间”之间旅行,每个房间都包含在 CCScene 中。当玩家退出一个房间时,下一个房间会通过 cocos2d 提供的精彩内置过渡“滑”到屏幕上。
问题是,我的 UI 控制元素保留在屏幕上至关重要。它们位于屏幕的底部,而游戏区域位于顶部。然而,看起来实际上可能没有办法限制 CCScene 的大小,使其仅占据屏幕的一部分。
我希望我可以告诉 cocos2d 让 CCScene 节点占据比全屏更小的空间:
CCScene* scene = [CCScene node];
scene.contentSize = CGSizeMake(200, 200);
但到目前为止,这样的方法还没有起作用。 CCScene 始终占据全屏。如果我必须将 UI 控制元素完全移出 cocos2d 才能使其正常工作,使用视图控制器等等,我什至可以接受。但现在我很好奇我想做的事情是否可以在 cocos2d 中实现。
I am working on an iOS action game wherein the player travels between various "rooms," each of which is contained in a CCScene. When the player exits a room, the next one "slides" onto the screen via the wonderful built-in transitions provided by cocos2d.
The problem is, it's critical that my UI Control elements stay on the screen. They live in the bottom portion of the screen while the playing area is at the top. However, it appears that there may actually be no way of limiting the size of a CCScene so that it occupies only part of the screen.
I was hoping I could just tell cocos2d to make the CCScene node occupy a space smaller than the full screen:
CCScene* scene = [CCScene node];
scene.contentSize = CGSizeMake(200, 200);
But so far nothing like that has worked. The CCScene always occupies the full screen. I'm even okay with it if I have to move my UI control elements completly out of cocos2d to get this to work, using view controllers and what not. But right now I'm curious if what I'm trying to do is even possible within cocos2d.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请查看 cocos2d 测试目录中的 EAGLViewTest 。本测试项目的目的是仅在指定的矩形区域中使用cocos2d。它由 EAGLView 指定。您可以使用 Interface Builder 来实现它。
Please take a look at EAGLViewTest in cocos2d tests directory. The intent of this test project is to use cocos2d only in the specified rectangle area. It is specified by EAGLView. And you can use Interface Builder for it.