Cocos2d-x mobile games entry navigation, cocos2d-x entry navigation

Source: Internet
Author: User
Tags dota

Cocos2d-x mobile games entry navigation, cocos2d-x entry navigation

I. Why should I write this article?

Cocos2d-x game engine has been out N years, online tutorials a pile of, But why so two I want to write an entry navigation? Isn't the blind lamp useless wax? After giving you so many questions, let's answer them.

The entry navigation article is not for Daniel and experts, but for the next entry of our team's newcomers. In this blog, we need to make a navigation for the newcomers, at the same time, I also use this navigation blog to test whether new users are willing to move to the mobile application field. Mobile Internet is already booming, except for games, which are currently the most popular applications. Of course, mobile games are steadily improving. Although I don't know when mobile games will become dull, but at least now it seems to be a good prospect. With the next introduction of the new users to start the game engine cocos2d-x, the test of their newcomers are willing to do a career in the mobile application field.

2. Introduction to cocos2d-x Engine

What is a cocos2d-x engine? Why is it an engine?

As the name suggests, an engine is an automobile engine. It is like a human heart. All power of the human body and power of the automobile are derived from the engine, with the engine, you can easily build the mechanical equipment you want (without worrying about the domestic mechanical engine development capabilities ), of course, the engine here is only a technical meaning of the mechanical engine, and it is not something that can be seen and touched by physical objects. The game engine is the heart of a game. With the engine, you can build your applications in the shortest time and use the convenient features in the engine to easily implement the game functions you want.

Cocos2d-x game engine as the current domestic mobile game engine share the first engine, have to say that its huge advantages have been rapid development capabilities. With the cocos2d-x engine you can easily achieve cross-platform (cross-platform do not know what it means? Juvenile, Baidu). It's no exaggeration to write it once and run it everywhere.

As the entry navigation of the game, next I will introduce the cocos2d-x development of the general model of the game and the operation process.

Iii. Introduction to engine development games

In the cocos2d-x game engine, the use of node tree structure to manage the game, a game only one director to manage each part of the game, A game can be divided into different scenarios? Young man, think about how movies are shot. A scene can be divided into different layers (not understanding the layers in the game? You should know about movie footage. A layer can have any visible game Node (that is, the object. All the classes in the game inherit from the Node class Node ).

The following is a diagram of each concept:


Director-Director

A game is like a movie. In a movie, you are just an audience and cannot change the plot as you think. Different in the game, it is more interactive. Cocos2d-x game engine to co-ordinate the overall situation of the game class (do not understand what is called class, first put, the latter will understand) Abstract To the Director-ctor, Director is the core of the entire game, it is the navigator of the entire game. Some common operations in the game are controlled by ctor, such as switching game scenarios, pausing the game, and converting coordinates in the game world, and control the elements in the game (elements do not understand, young man, think about the hero you play in Dota.

At the same time, the game data and screen size acquisition are controlled by ctor.

Director is the chief Director in the game and the only highest conductor. For example, the title Director is the boss and the only leader. It cannot be replaced, therefore, in the game, ctor adopts the singleton mode (you do not know the singleton mode, but you can release it first, and you will understand it later). A game uses a Director to make overall plans.


Scenario -- Scene

Scenes are indispensable in the game. For example, if a movie has no shooting place, it is useless to have a director. A game usually requires at least one scenario (have you ever seen only one scene in that movie? Oh, you don't have any children, 23333). switching between checkpoints and sections in the game is one scenario. It's like switching between the video and the camera in a movie, qi tianda Sheng is on the runway from the old Yudi old son, And the level switching in the game is also a truth. A scenario plays an important role in Process Control. The logical arrangement of different scenes in a movie forms a good movie. In the same way in the game, the combination of different scenes builds a complete and fun game.

The Director controls the switching of scenes, and all the process control is decided by the Director. Who makes people the boss. The method used by the Director to control the scenario is to call different functions (the function is unknown? You should know about the Black Box, plug in the necessary things, and get out the things you want. This is the function). Different functions can have different effects. I will not discuss them carefully here.

Is there any scenario in the game? What if there are no actors in the movie? What do you think is a natural documentary? There are also big trees and birds and insects in the documentary. The scenario is just a container in the game. Everything displayed in the game is included in this scenario. Of course, the most important thing included in the scenario is Layer.


Layer-Layer

What is layer included in the scenario? Almost all elements of the game players see are displayed on the layer, such as the tree, road, hero, and hero skill display in the game. At the same time, layer receives user input events, such as touch, accelerator, and keyboard input. There can be different layers in the game. Each layer shows different things. When all layers in the game are combined, different elements in each layer are mixed together, it constitutes a complete game interface. Let's take a look at the presentation of the layer below.

Three Layers Layer1, Layer2, and Layer3 are displayed on the top of the stack. The Layer1 layer is located at the bottom of the stack, and Layer3 is located at the top of the stack, both Layer1 and Layer2 are blocked. This is the effect of the layer. The top layer shows all of them, and the following layers are blocked in sequence. Each layer has its fixed content, which is used to separate different elements in the game in order to facilitate the management of a certain kind of things. For example, the plants in the game are a layer, all the logical relationships and representations of plants are in this layer. Even if a problem occurs on this layer, it is only a problem on this layer and will not affect other elements in the game. The separate layer is modular, which facilitates management and development by many people.


Sprite

The layer is introduced above, but the concept of a light layer does not have an object in the layer to form a game. All the things in the game that can move or have specific behaviors are called Sprite, sprite allows you to move, rotate, scale, execute an animation, and display other effects.

The most typical Sprite is like a hero in Dota. Every hero is an independent genie. Players can control the actions of the genie through input events in the layer, such as jumping, or launching bullets. The genie is the smallest unit in the game and the most flexible thing in the game. The quality of the game is almost displayed by the genie, just like the actors in the movie. All the things seen in the game are generated by pictures, and the genie is no exception. Anyone who knows about cartoons should know that cartoons are displayed by a group of pictures for quick play, the same is true for Genie. Different Combinations of images can have different effects. The quality of a game depends to the maximum extent on the creation of images. It can be said that the key to the success or failure of a game lies in the artist, show users well, users like it, otherwise your game will fail, even if the strategy is good, it will be useless.


The above describes the four most basic elements in the game. It is far from enough for a game to have such knowledge. However, the basic composition of each game is like this, but the intermediate implementation effects are different, as an introduction to the cocos2d-x game engine entry, is also a test of the first level of the new users of the content, the above introduction is enough, as a newcomer to read the above things, you should think about a few small questions. Otherwise, when the boss asks you, you may be confused. What is the problem? This requires self-mining from the text.

Well, as an entry to the cocos2d-x, Daniel and master can float, was not prepared for these people, the above introduction has no place, the villain's ability is limited, it can only be introduced here.



Is it difficult to develop mobile games? Where do I want to learn Cocos2d-x?

Cocos2d-x is an open source mobile 2D game framework released under the MIT license. If you have the foundation, Cocos2d-x is not difficult to learn, if you want to learn Cocos2d-x, find the video of LIU Hui teacher to see, Liu Hui teacher as the first person in China Cocos2d-x video tutorial, has 15 years of IT experience. His video can be viewed on the video website and on the blue ocean Internet.

Ready to transfer to the hand game, is it generally do 2D if you choose Cocos2D-X, 3D on the selection of Unity3D?


At present, the most popular and mainstream game engine in China should be regarded as a cocos2d-x, many people are using, there are also a lot of successful cases, more than half of China's mobile gaming April journal shows using the cocos2d-x engine, including "My name is MT", "Fishing talents", "dazhangmen", "World OL", "Forget fairy", "the power of the Dragon", "King 2", and "The spirit of the Fairy". For more information, see.



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.