How can I implement a virtual joystick for playing cocos2d outside of cocos2d?

I am developing an iPad game that uses cocos2d and requires a virtual joystick. My prototype works and works with SneakyJoystick.

However, I realized that for my game project I need to use CCTransitions to move the user between different instances of CCScene to get the visual effect that I want. The problem is that I don’t want user controls (like a joystick) to be exposed to CCT transitions - I want them to stay on the screen (in a different part of the screen than the part occupied by CCScene.)

I realized that the only way to do this is to save the entire cocos2d environment in EAGLView, which occupies a smaller area than the entire screen, which allows me to store all user controls in a different place on the screen where they are not affected by scene transitions.

The problem is that SneakyJoystick is probably no longer an option, as it is a CCNode, so it will probably only work inside the cocos2d scene graph.

I am curious if anyone has an alternative solution for this situation: a way to implement a virtual joystick outside the cocos2d environment, but it can somehow exchange information with the cocos2d scene.

It would be great if I could save the SneakyJoystick functionality or something very similar, either by clicking on the planned cocos2d updates from this non-cocos2d class, or otherwise by clicking on the user data entry from the joystick class in cocos2d.

+3
source share
1 answer

Perhaps you can create a UIView and put it on top of the opengl view. To access openglView use [CCDirector sharedDirector].openGLView. Create your joystick using UIView. Therefore, it will always be displayed and will not be affected by CCScene transitions.

+1
source

All Articles