The idea of a systematic understanding of this problem arises because of a problem we just encountered today.
Recently I was writing a parkour game, based on cocos2d-x. When determining the death, there is a situation where the main character is
Random Number is often used in the program, the cocos2d-x uses CCRANDOM_0_1 to generate a random number, but we finally pass it into a random number seed, so that the random number is the real random number, this seed is the time we generally use.
If the development environment does not have the reflection function, it takes a lot of effort to rename the code. The following code replaces variable names in batches. Modify many situations that can be used for code conversion.
This article is
Reprinted please note, original address: http://blog.csdn.net/jinble03/article/details/20006407Introduction: If you want to gain an in-depth understanding of the entire framework and running process of the cocos2d-x, if you want to know the details
1. Prepare the environment
Install the latest version of python 2.7, http://www.python.org/download/releases/
Download cocos2d-x 3.0bate2,: http://www.cocos2d-x.org/download
2. Create a project
Enter the: % cocos2d-x 3.0bate2% \ tools \
The normal selection won't be mentioned here. As provided in box2d, a quick selection class with relatively high efficiency is b2QueryCallback.
#ifndef QueryCallback_H#define QueryCallback_H#include
class QueryCallback :public
In our game development, apart from the UI being the top priority, music is also an indispensable part.
Because people have two eyes and ears.
Now let's take a look at the introduced library files, which is relatively simple in general.
First
RAC uses a large number of blocks in applications. Because the Objective-C language memory management is based on reference count, to avoid the issue of circular reference, if you want to reference self in the block, use @ weakify (self) and @
The avi version can be conveniently viewed on mobile phones and PCs.
1. Play background music and real-time music
# Include SimpleAudioEngine. hCocosDenshion: SimpleAudioEngine: sharedEngine ()-> audio); // real-time music cococosdenshion:
In the previous article, we used Sprite as an example to analyze the registration function. However, we seem to have omitted a point, that is, the constructor. Because the Cocos2d-x in the C ++ layer uses workshop functions to generate objects,
Previously Used version is 2.0.1 version, and later with 2.1.1 re-write a part, now brand new start, with the latest version, cocos2d-x-3.0beta, this version and the previous changes quite large.
This is the background material.
Program
In March April, it took nearly two months to create a simple anti-tower game, three monsters and three towers. I learned a lot. The planning and art programs are all done by myself, so the ideas have changed a lot, the procedures have been improved,
1. Create a UI using cocostudio, create a UI, and add a LabelAtlas and a LabelBMFont respectively. Export the project, save it as cocos2d3sampleui_playScene.ExportJson, and add it to the Resource Directory of xcode together with the related Resource
The success of a game depends largely on the success of the animation. Readers familiar with cocos2dx know that it has many ready-made animations. In this section, I will make little monsters move forward slowly;
The running effect is as follows:
Game image resources need to be packaged, this chapter I will introduce the cocos2d-x editor Paster (TexturePacker );
The principle of textures is to combine a small image set. If an image is large (such as a background resource), it must be placed
I think everyone should have encountered this situation. When writing code in VS, You need to display Chinese characters in the Label, the Code is as follows:
Auto m_label = LabelTTF: create ("Happy New Year! "," Arial ", 25); m_label-> setPosition
In this section, I will add background music and sound effects to the game;
Create a new sounds directory under the Resources directory and copy the prepared sound effects to the directory;
Open MainLayer. js and modify the Code as
Next, let's talk about some adjustments to the CCLOG macro.
Most of the time, when the debugging program cannot break a breakpoint, or when it is not convenient to break a breakpoint, it can only rely on LOG output. Therefore, a convenient
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