Last lesson we explained the Cocos2-x v3.7 version of the download installation, also shows the use of Cocosstudio to compile different platforms to execute the program, you are not the new version of the Cocos engine full of expectations? Today we will create a project to show you what new changes cocos2d-x v3.7 to create Hello world.
Courses in this lesson video address: http://edu.csdn.net/course/detail/1342/20981?auto_start=1
Fire Cloud Development Classroom Forum Address: http://www.firestonegames.com/bbs/forum.php
Create Hello World Project
First, we start our Cocos engine software, select the "Project" option and click "New Project".
and then select Cocos projects,
then we can see the options that are required to create the project:
Here we give the project a name called HelloWorld , the path to the project is placed in the Code folder of the desktop. Screen orientation We choose horizontal screen, engine version or select cocos2d-x v3.7 version, Project language select C + +. Click Finish after selecting the above options. The project is created, and the Cocostudio will pop up automatically,
we can see a noun for "Mainscene" scene was created, there is a classic cocos background in the scene, but the lack of this text label "Hello World" is obviously unacceptable to us, and God says, "Be sure to have a hello world!." We found the "text" option in the control Panel on the left,
We drag "Text" to the "Mainscene" inside. So we can create a new text tag, and then we'll modify the new "text" property, and we'll check "text" in the Properties section to make changes.
We can change the name of the text in the "name" option and change the coordinates of the text in the "coordinates" option.
in the "text" option we're going to write "Hello World" . Then we can change the color of the text display, the size of the font. We can see a "Import font file" option below, what is this option for? If you have Cocos development experience, you can certainly guess, it is very useful, more useful I do not tell you now (haha, a joke, when we say the label will be explained in detail).
after we've done this, our"Hello World"It shows up and we're going toCOMMAND + S(Win above isCtrl + S) to save,COMMAND + P(Win above isCtrl + P) to publish the Cocostudio file.
Engineering Catalogue Analysis
We open the project catalog for the projects we created,
When we double-click Helloworld.xcodeproj, the Xcode development tool is launched. We can see the project catalog:
from the project catalog we can see that the new version of the Cocos engine created by the project, and before the same, it should be said to be very different. First of all, there is only one HelloWorld project left, and the previous Cocos2d project is gone. In the Resources There is a MAINSCENE.CSB, this east is what we just created in the Cocostudio, with our "release", That is, when you press COMMAND + p, he will spawn.
from the project catalog we can see that the new version of the Cocos engine created by the project, and before the same, it should be said to be very different. First of all, there is only one HelloWorld project left, and the previous Cocos2d project is gone. In the Resources There is a MAINSCENE.CSB, this east is what we just created in the Cocostudio, with our "release", That is, when you press COMMAND + p, he will spawn.
Look at the picture we look closely at the red labeled. A static library, this thing is why, it is cocos2d-x project compiled static library, we can not find Cocos Engineering source, because he has been turned into a static library put here, then you may ask, what to compile static library, this is because, after compiling the static library our Compile speed is much faster, very much, before compiling a newly built project, it is very time-consuming, I i7 four core, 16G memory, plus 256 flash high-fidelity Computer configuration to compile 5 minutes or so, I basically are just beginning to compile the project on the table sleep, sometimes woke up not compiled well, said exaggerated point, The compile time is enough for Bolt to turn around the Earth three times. Using a static library now perfectly solves the problem of slow compilation. So "Mom never had to worry about me falling asleep when I was compiling the project." Of course, using a static library can also make your project run smoother.
We run the project and will see:
Detailed Engineering Code
Let's take a look at the code below.
HelloWorld is the new Cocos2d-x layer class, with only three functions in the header file, which is familiar to anyone with a slight experience with the Cocos2d-x engine. I have added a note that you can understand for yourself.
Let's take a look at the source files for HelloWorld:
As you can see from the comments, the biggest difference from the previous version of Cocos2d-x is that it has not created the Cocos background and HelloWorld text labels in the code. Instead, the Cocosstudio binary information file is read directly by a loader called Csloader. This little change, in fact, represents the great progress of Cocos, which shows that the development of Cocos has entered the era of instrumentation, a change that requires us to pay more attention to the use of Cocos Integrated editor Cocosstudio in the future. (By the way: as Cocosstudio once the product director, Red Baby teacher participated in the design and development of Csloader, because many netizens to red baby teacher spit slot Cocosstudio load json too slow, Red Babe teacher efforts to change this part into a compatible JSON format of the CSB binary files, in the format of the ultimate optimization, the final load speed greatly improved! )。
Well, today's our about the HelloWorld project to create and explain it here, thank you.
Homework:
Create a Cocos project.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Create the first project: HelloWorld