cocosd2d Instance Tutorial (V) cocos2d Add Virtual Joystick controller

Source: Internet
Author: User

1. Introduce

Cocos2d for us to provide a good joystick controller, mainly for the ZJoystick.h and ZJOYSTICK.M add to achieve the following diagram function. You can control the movement of the sprite in the diagram by using a joystick. (But there is still a technical problem to be solved, that is, the sprite will be moved after a shadow left in the original position)

2. The realization of the rocker pole

1 The resources of the Zjoystick folder added to the project (below the page to provide download address), the wizard to add and move the previous said, do not know students can see the tutorial four. Project name is controlwalking

2) Modify the HelloWorldLayer.h file. Add some of the required node parameters.

#import <GameKit/GameKit.h>  
      
//When your import this file, you import the cocos2d classes  
#import "Cocos2 D.h "  
#import" ZJoystick.h "  
//Helloworldlayer  
@interface helloworldlayer:cclayer<zjoystickdelegate >  
{  
    cctexture2d *spritetexture_;    Weak ref  
    //b2world* world;                   Strong ref  
    //glesdebugdraw *m_debugdraw;       Strong ref  
          
    //cctmxtiledmap *_gamemap;  
    Ccsprite    *_player;//is a genie, the panda in the picture is  
      
//Returns a ccscene that contains the Helloworldlayer as the only child
  + (Ccscene *) scene;  
      
@end

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.