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:Man is the product of habit, when you are accustomed to happiness. The unhappiness in my memory disappears.
before the game starts After 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 the button, but a complete and useful game is still very far away. In this chapter, we will first put aside cocos2d to introduce the basic concepts of game development. then combined with 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 flowprogram control system, scene, layer and sprite.
scene and Process ControlI believe that we have been exposed to many different types of games while facing most games. Players can start playing the game almost without learning. Because they all haveFor example, the following process:into the game. Display the main game menu;Choose a new game, start teaching tasks or the first level;choose to load the game and continue the game ever. Select Settings. Adjusts the game's auditory or visual effects. to find small three as an example, assuming that the process of drawing it into a diagram, you can get the following flowchart to find small three. Through this flowchart. We'll be able to stream the gamethe process has a clearer understanding.
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. In general, we refer to a set of game elements that are relatively constant in this context, called scenes, tothe process of the game switching between scenes is called Process Control.
in the Cocos2d-x 3.0 . The implementation of the scene is scenes.
Layerlayers are game elements that are subordinate to the scene. Typically, a complex scene has multiple layers, and a layer displays a subset of the visual elements. The blank part is transparent orTranslucent. 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 touched the pictureEditor (such as Photoshop) or an animation editor such as Adobe Flash, there is also a layer concept in these editors. In game design, the concept of layerssimilar to them.
To find small Three's game scene as an example, the scene can be roughly divided into 4 layers.
background layer: background image. Menu Layer: The various menu items that hover over the top. Touch layer: Handles touch, swipe, etc. on the screen . 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".
The background layer is included. and button touch layer;
the same is true for the same game layer, which contains a draggable background layer. Button layer. props layer, etc.;
in Cocos2d-x 3.0, the layer is implemented in layers.
elflayers and scenes are containers for other game elements, assuming they are always transparent without adding visible game elements to them. Sprites are associated with layers or scenesdifferent, it belongs to the layer. is a visible graphic that appears in the scene.
Player-controlled protagonist, AI-controlled NPCs, and chests and stones on the map. Even the background images of the main game menu are sprites. So. Can feel that way. What the player sees is almost always composed of elves.
The genie is not necessarily static. Usually. An elf can change in a way that includes: move, rotate, zoom, deform, show disappear, animate (like GIF animation), etc. Sprites are grouped together in a hierarchical structure. and interact with the player, forming a complete game.
Taking the "find small three" game scenario as an example, we choose the game action layer, which includes the main elves to see.
node and render tree We already know how sprites, layers, and scenes form a framework for a game.
The sprite belongs to the layer and the layer belongs to the scene. The player interacts with the sprite and causes the game screen to switch between different scenes.
Stitch each link together. We got a complete diagram.
therefore. The diagram essentially arranges the drawing of Graph, each element in the diagram is called a node, and the diagram is called the Render tree (rendering). The process of rendering the scene is to traverse the The process of rendering the tree.
We give each node a series of attributes, including the position of the node relative to the parent node, the spin turn angle, scale and deformation parameters, etc. The advantage of the rendering tree is that we only need to consider the properties of the node relative to the parent node. It is possible to create complex
Span style= "line-height:1.8; Color:rgb (38,38,38) "> Find small three " in the background animation. Time travel, The Earth is constantly turning, and the trees and buildings are turning.
Therefore, the ability to create a node to represent the background. 2 more elves were created to represent the protagonist and the Earth.
In this way, each action is controllable, only to set the action for each sprite, you can complete the complex animation. Conversely, if there is no tree structure, organizing a slightly complex walk will become 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). mentioned earlier. Usually the game is organized according to the order of scene, layer and Sprite, each node has its own characteristics. However in the actual development. In order to achieve some special effects, you do not have to rigidly adhere to this level of order. A layer or sprite is a normal node. Therefore, the wizard is added to the sprite. Adding sprites to the scene, or even adding layers to the sprite, are 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. To make the game screen move, we create a series of actions when needed, and apply them to the game elements.
in Cocos2d-x, actions are implemented by the action class. The action class derives from the persistence action class Actioninterval and the instantaneous action class actioninstant.
The
All actions are derived from one of the two classes above.
animation (animation) is a special kind of continuous action, It can only be applied to sprites to achieve frame animation effects.
Like film footage, a frame motion is constantly switched on and off by a number of delicate images. 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. Distance produces beauty, but also can produce small three, so the protagonist is constantly walking around looking for. seem extraordinarily real.
in Cocos2d-x, we are able to create frame animation sequences (Animation) using multiple frames and create frame animations that can be used for sprites with frame animation sequences (Animate).
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
6, COCOS2DX 3.0 The basic concept of game development to find a small three games