Description of the overall framework of Cocos2d-x Learning

Source: Internet
Author: User
1. Overall Cocos2d-x description

Like traditional game engines, cocos2d-x, as a 2D game engine, has the following concepts:

Director (ccdiretor ):

In the cocos2d-x engine, ccdirector class is the core of the entire game organization and control, game running rules, in-game ccscene (scene), set (cclayer), role (ccsprite) the ccdirector Ctor is used to manage the games. In the game, ccdirector specifies game rules to enable orderly running of scenarios, scenarios, and tasks in the game. In the entire game, there is usually only one director. at the beginning and end of the game, you must call the ccdirector method to initialize or destroy the game. It provides some scenario management methods, such as runwithscene, drawscene, pushscene, and replacescen.

It controls FPS display hiding, window size, game entry, exit, level switching, orthogonal mode, running scenario, GL view, and main loop entry.

Camera (cccamera)
Each node in the game requires a camera. When the node scales, rotates, and positions change, the camera must be overwritten so that the node can be re-rendered through the camera.

The official description of the camera is as follows: cccamera is applied to each ccnode. The glulookat function in OpenGL is used to locate the camera. If this object blooms, rotates, or translates, these operations modify the camera. Note: You can only select one of the camera's rotation, bloom, and translation attributes. If you use the camera, the world coordinates will become useless. Limitations: several nodes, such as ccparallaxnode and ccparticle, use the coordinates of the world node, and they cannot work normally, if you use a camera to move them (or any of their parent classes ). In batches of nodes (that is, a node contains multiple nodes), such as ccsprite objects do not work normally when they all belong to a ccspritebatchnode object. We recommend that you use this function only when creating 3D effects. For 2D effects, it is better to use ccfollow action or translate, bloom, and rotate.
Scenario (ccscene)
In a game, a scenario is a level. The level consists of the role and background. In a movie, scenes are various scenes in the movie. Various scenes are mainly composed of activities and backgrounds of characters. In the Cocos2d-x engine, the scene is stored in the scene that needs to be rendered, the task role and menu, it can be used as a whole, rendering together, destroying together, and switching together.

That is, the implementer of the game level, which manages multiple cclayers for scenario presentation and related business logic processing;
Set (cclayer)
In terms of concept, a set of scenes is the background of a scenario. Actually, it is the concept of hierarchy. This concept already exists in the kjava era, that is, it is to manually layer the scenes in the game (also implemented by the map editor ).
Each game scenario can have multiple layers. Each layer has its own responsibilities and tasks, such as displaying the background, displaying items, and displaying task roles, different elements can be placed on each layer, including text, Genie, and menus, we can easily control and display a variety of interfaces. Of course, it is also transparent like the layers in Photoshop, so in order to be able to see what is above each layer, multiple layers are set to transparent or translucent. Otherwise, you can only see the top layer.

Generally, a scenario can have many layers, such as the background layer, the object layer, the NPC layer, the role layer, and the UI Layer. Each layer is responsible for its own functional business, and always coexist in a ccscene, the scenes are hidden. Different layers can be displayed and controlled by setting different Alpha channels (transparency;
Role (ccsprite)
Genie is the main object of the game development and processing, including the protagonist and the enemy, NPC and so on, even a random floating cloud or birds technically speaking, is also the genie, because the genie in the cocos2d-x, it is an image that can be changed constantly. These changes include position change, rotation, zoom in and out, and motion.
Action)
The actions of a role are generally used when an genie occurs, such as moving or releasing magic.

In general, the above objects are mainly associated as follows:

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.