6, COCOS2DX 3.0 game development to find small three the basic concept of the game

Source: Internet
Author: User

re-developer of labor results, reproduced when please be sure to indicate the source : http://blog.csdn.net/haomengzhu/article/details/27689713

Shimen Main Friendship tips:people are the product of habit, when you are accustomed to happy, the unpleasant in memory disappears.
before the game startsAfter the previous study, we have been able to develop a major cocos2d-x game, this game contains a background picture and an exit game by thebutton, but a complete and useful game is still very far away.

In this chapter, we will first put aside cocos2d, introduce the basic concept of game development, and then combine the characteristics of cocos2d-x. Introduce some basic knowledge of cocos2d-x development. Although there is no detailed way to explain the game development, it will be slightly dry , but the introduction is the basic knowledge that cocos2d-x development must understand.


Basic Concepts To develop the game, first understand the fundamentals of the game and the composition of the elements.

In this section. We will introduce the basic concepts in the game, including the game flow Program control, scene, Layers and sprites.


scene and Process Control I believe we've been exposed to a lot of different types of games. , while facing most games. Players can start playing the game almost without learning. Because they all have For example, the following process: Span style= "font-family:kaiti_gb2312; Font-size:18px "> Enter the game, show the main menu of the game, Choose a new game, start teaching tasks or the first level Choose to load the game, continue the game; select settings. Adjusts the game's auditory or visual effects.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvzgfuawvsenp1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "

In the diagram, the content displayed in each node is relatively constant. Usually. We refer to the set of game elements that are relatively constant in this context, called scenes, and
in Cocos2d-x 3.0 , the implementation of the scene is scenes.


Layer layers are game elements that are subordinate to the scene. Usually. A complex scene will have multiple layers, one layer will display a portion of the visual element, and a blank part is transparent or translucent. To achieve overlapping display of multiple layers.

The layers are stacked in order with each other. Makes up a complex scene. Perhaps the reader has been exposed to a picture composer (such as Photoshop) or an animation editor (such as Adobe Flash?). The concept of layers also exists in these editors.

In the game design. The concept of layers is similar to theirs.


Span style= "COLOR: #262626" > Background layer: Background image. menu layer: Various menus suspended at the top 。 Touch layer: Handles touch on the screen, Slide screen, etc.

Action layer: Use skills, etc., and handle touch.
What we see is the layering of the main menu scene and the game scene of "Looking for small three".

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvzgfuawvsenp1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
It contains the background layer, and the button touch layer;

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvzgfuawvsenp1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ",
Same as the game layer, Contains a draggable background layer. button layer, prop layer, etc.

Genie layers and scenes are containers for other game elements. Assume that no visible game elements are added to them. They always seem to be transparent.

Sprites are different from layers or scenes , which are subordinate to layers and are visible graphics in the scene. Player-controlled protagonist, AI-controlled NPC. and the treasure chests and stones on the map. Even the background images of the main game menu are sprites.

So, I can feel that way. What the player sees is almost always composed of elves. The genie is not necessarily static. Often, an elf can change in a way that includes: move, rotate, scale, deform, show disappear, animate (like GIF animation), and so on. Sprites are combined in a hierarchical structure and interact with the player to form a complete game.
Take the game scene of "Looking for small three" as an example, we choose the game action layer. Among the main elves that are seen.



node and render tree We already know how sprites, layers, and scenes form a framework for a game.

The elves belong to the layer. Layer belongs to the scene, the player interacts with the elves, and causes the game screen to switch between different scenes. By stitching each link together, we get a complete diagram. As an example of a simplified version of the "find small three" game scenario , each game element is organized in the same way as the diagram sees it.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvzgfuawvsenp1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ",
The process of rendering the tree.


Once the rendering tree is established, it is easy to organize complex scenes. We give each node a series of attributes, including the position of the node relative to the parent node, rotation angle, scale, and deformation parameters.

The advantage of a rendering tree is that we can create complex objects or actions layer by level only by considering the properties of the nodes relative to the parent node .


to give a simple example is the looking for small three "in the background animation. Time travel. The earth is constantly turning. The trees and buildings were turning .


Therefore, the ability to create a node to represent the background, and then set up 2 sprites to represent the protagonist and the Earth respectively.

In this way, each action is controllable, just set the action for each sprite. The complex animation can be completed.

Instead. Assuming there is no tree structure, organizing a slightly complex walk can be a huge project.
Cocos2d also uses a rendering tree schema.

No matter what visual game elements are derived from the Cocos2d-x node, common game elements are scene, layer, and Sprite (Sprite).

As mentioned earlier, the game is usually organized according to the sequence of scenes, layers and sprites, each of which has its own characteristics.

However, in the actual development, in order to achieve some special effects, it is not necessary to rigidly adhere to this level of order. Layers or sprites are common nodes, so add sprites to the sprite, add sprites to the scene, and even add layers to the sprite. These operations are also not prohibited. When the reader thinks it is necessary, he can try various organizational levels from himself.


Motion and animation Action acts on the elements of the game, allowing the game elements to move together. Common movements are moving, rotating, flashing, disappearing, and so on.

The action is divided into continuous action and instantaneous action. Continuous action is completed over a period of time. Instantaneous action will be completed instantaneously.

For the game screen to move up. We will in Cocos2d-x, Actions are implemented by the action class. The Action class derives from the persistent sex action class Actioninterval and instantaneous action class actioninstant. All actions are derived from one of the above two classes.
animation (animation) is a special kind of continuous action, It can only be applied to sprites to achieve frame animation effects. Like a film film, a frame moves painting by a number of exquisite pictures are constantly switching to form.

A delicate picture is called a frame. The sequence of frames represents an animated effect. For example, "Find small three " in the game. The Earth is constantly turning, the distance to produce the United States, but also to produce small three, so the protagonist is constantly moving around looking for, appear exceptionally real.
in the cocos2d-x. We are able to create frame animation sequences (Animation) with multiple frames and create frame animations (animate) for sprites using frame animation sequences .

6, COCOS2DX 3.0 game development to find small three the basic concept of the game

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.