Cocos2d-x learning notes (2) Cocos2d-x overall framework, cocos2d-x learning notes

Source: Internet
Author: User

Cocos2d-x learning notes (2) Cocos2d-x overall framework, cocos2d-x learning notes

Original article, reproduced please indicate the source: http://blog.csdn.net/sfh366958228/article/details/38680123


In the previous section we briefly analyzed the HelloWorld project, and we will look further at the overall framework of the Cocos2d-x.

Before learning about the overall framework of Cocos2d-x, let's think about what a movie needs?

With these basic conditions, the directors, stages (Scenes), set sets, and actors can perform different actions based on the script.

Similarly, to make a game is like shooting a movie, you also need these elements, and the Cocos2d-x just provides the corresponding.


Director-CCDirector

In the cocos2d-x engine, CCDirector is the control core of the entire game, using it to make the various scenes of the game orderly, and through the way of stack, scene management. CCDirector is a singleton that can be obtained through the CCDirector: sharedCCDirector () method. Therefore, in the entire game, there is generally only one director who needs to call it to initialize and destroy the game image.


Void runWithScene (CCScene * scene); // stack and activate the scenario (applicable only to the first Scene of the entire game, which is used in the AppDelegate of the HelloWorld project) void replaceScene (CCScene * scene); // stack and activate a new scenario. The old scenario is output from the stack and void pushScene (CCScene * scene) is cast ); // Add the new scene to the stack and activate void popScene (); // The void pause () of the scene output stack; // pause the scene rendering and activity void resume (); // restore Scene Rendering and activity CCSize getVisibleSize (); // obtain the displayed area size (used in the AppDelegate of the HelloWorld project )//...


Scenario-CCScene

In the game, the scenario is the level. Different Levels are implemented and switched through different scenarios.

In the Cocos2d-x, scene memory places the scenes to be rendered, they as a whole, rendering together, destroy together.

It inherits from CCNode and is used to contact all CCNode nodes.

This method is required to create a CCScene:

Static CCScene * scene (); // generate CCScene


Set-CCLayer

It is inherited from CCNode and can be understood as a layer. It is used to layer scenes in the game manually. Each game scenario can have multiple layers and each layer has a single responsibility. For example, some layers are responsible for the background, some layers are responsible for displaying items, and some layers are dedicated for displaying the UI. Through the relationship between layers, we can more easily control and display various interfaces. In order to be able to see what is above each layer, the layers are generally transparent. Of course, you can use CCColorLayer to create a background color layer.

CCLayer can be used to accommodate other CCNode nodes for single-point touch, multi-point touch, and gravity sensing callback.

Virtual void onEnter () // The callback function when entering the virtual void onExit () // The callback function when leaving the virtual void onEnterTransitionDidFinish () // The callback function virtual bool ccTouchBegan (CCTouch * pTouch, CCEvent * pEvent) // virtual void ccTouchesBegan (CCSet * pTouches, CCEvent * pEvent) // multi-point touch screen event virtual void ccTouchesMoved (CCSet * pTouches, CCEvent * pEvent) // virtual void ccTouchesEnded (CCSet * pTouches, CCEvent * pEvent) // The Touch Screen movement time ends. virtual void ccTouchesCancelled (CCSet * pTouches, CCEvent * pEvent) // the touch screen event cancels virtual void didAccelerate (CCAcceleration * pAccelerationValue ); // gravity sensing event //...

Actor-CCSprite

Inherited from CCNode, It is a 2D image. CCSprite can be created through an image or a rectangular subarea in the image.

CCSprite is an important object to be processed throughout the game development process. Most of the major objects are implemented through CCSprite, such as the main character, the BOSS, and the ghost cloud that floated across the sky.


Action-CCAction

As long as it is a subclass of CCNode, You can implement the action through CCAction.

There are many CCAction categories, which will be detailed in the following study notes.




Cocos2d-x tutorial

[Mcco cocos2d-x cross-platform course]

The course content is divided into five phases:
The first stage focuses on understanding and understanding game development and preparing for game development;
The second stage is to learn how to use the cocos2d-x engine for game development, it contains the basic knowledge of cocos2d-x engine in all aspects;
In the third stage, we will learn some common technologies in game development, including the use of networks, security, optimization, and editors, as well as the characteristics of mobile devices and the current market environment, make the game popular;
In the fourth stage, the game engine itself is analyzed to meet various expansion needs in game development, and even to develop and improve the engine itself;
The fifth stage is mainly based on actual commercial projects, allowing everyone to master the whole process of game development, including planning, architecture, and management, so as to independently complete commercial and game projects.

Game Development novice teach Cocos2D-X how to learn, only C ++ development experience

Congratulations, cocos2d-x is written in c ++, theory can refer to the relevant cocos2d. There are many cocos2d communities on the Internet. Let's take a look! Visit more forums. We need to understand scenarios, layers, Genie, actions, and other related concepts.

Related Article

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.