我正在开发一个使用 cocos2d 并且需要虚拟操纵杆的 iPad 游戏.我使用 SneakyJoystick 建立并运行了一个原型.
I am developing an iPad game that uses cocos2d and requires a virtual joystick. I have a prototype up and running using SneakyJoystick.
然而,我意识到我的游戏设计需要我使用 CCTransitions 在 CCScene 的不同实例之间移动用户以获得我想要的视觉效果.问题是,我不希望用户控件(如操纵杆)受到 CCTransitions 的影响——我希望它们保留在屏幕上(在屏幕的不同部分,而不是 CCScene 占据的部分.)
However, I realized that my game design requires me to use CCTransitions to move the user between different instances of CCScene in order to get the visual effect I want. The problem is, I don't want the user controls (like the joystick) to be affected by the CCTransitions- I want them to remain on the screen (in a different part of the screen than the part occupied by the CCScene.)
我意识到做到这一点的唯一方法是将整个 cocos2d 环境保留在一个 EAGLView 中,它占据的区域小于整个屏幕,这允许我将所有用户控件保留在屏幕上的其他位置,它们不受场景转换.
I realized the only way to do this was to keep the entire cocos2d environment in an EAGLView that occupies an area smaller than the entire screen, which allows me to keep all the user controls elsewhere on the screen, where they are unaffected by the scene transitions.
问题是,这意味着 SneakyJoystick 可能不再是一个选项,因为它是一个 CCNode,因此可能只能在 cocos2d 场景图中运行.
The problem is, that means SneakyJoystick is probably no longer an option, as it is a CCNode that therefore will probably only run within the cocos2d scene graph.
我很好奇是否有人对这种情况有替代解决方案:一种在 cocos2d 环境之外实现虚拟操纵杆的方法,但它可以以某种方式与 cocos2d 场景进行流畅的通信.
I am curious if anyone has an alternative solution for this situation: A way of implementing a virtual joystick outside the cocos2d environment, but that can somehow communicate fluidly with the cocos2d scene.
如果我可以保留 SneakyJoystick 或其他类似功能的功能,那就太好了,方法是从这个非 cocos2d 类中利用 cocos2d 的预定更新,或者以其他方式将用户输入信息从操纵杆类推送到 cocos2d.
It would be great if I could retain the functionality of SneakyJoystick or something very similar, by either tapping into the scheduled updates of cocos2d from this non-cocos2d class, or somehow otherwise pushing user input information from the joystick class to cocos2d.
可能你可以创建一个 UIView 并将它放在 opengl 视图上.要访问 openglView,请使用 [CCDirector sharedDirector].openGLView
.使用 UIView 创建您的游戏杆.所以它会一直显示,并且不受 CCScene 过渡的影响.
Possibly you can create an UIView and put it over the opengl view. To access the openglView use [CCDirector sharedDirector].openGLView
. Create your joystick using UIView. So it will be always shown, and will be not affected by CCScene transitions.
这篇关于如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!