- Cocos2d-x by Example:Beginner's Guide(Second Edition)
- Roger Engelbert
- 345字
- 2021-07-23 20:00:23
Time for action – creating an application
Open Terminal again and follow these easy steps:
- You should have the path to the Cocos2d-x console already added to your system. You can test this by using the
cocos
command inside Terminal. In order to create a new project calledHelloWorld
, using C++ as its primary language and save it on your desktop, you need to run the following command, replacingYOUR_BUNDLE_INDETIFIER
with a package name of your choice, and replacingPATH_TO_YOUR_PROJECT
with the path to wherever you wish to save your project:cocos new HelloWorld -p YOUR_BUNDLE_IDENTIFIER -l cpp -d PATH_TO_YOUR_PROJECT
- As an example, in my machine this is the line I typed:
cocos new HelloWorld -p com.rengelbert.HelloWorld -l cpp -d /Users/rengelbert/Desktop/HelloWorld
And hit Enter. If you choose not to give a directory parameter
(-d
), the Cocos console will save the project inside theCocos2d-x
folder. - Now you can go to your desktop, or wherever you chose to save your project, and navigate to the folder
proj.ios_mac
inside theHelloWorld
project. Inside that folder you'll find the Xcode project file. Once you open the project inside Xcode, you can click the Run button and you're done.
Note
When you run a cocos2d-x application in Xcode, it is quite common for the program to post some warnings regarding your code, or most likely, the frameworks. These will mostly reference deprecated methods or statements that do not precisely follow more recent and stricter rules of the current SDK. But that's okay. These warnings, though certainly annoying, can be ignored.
What just happened?
You created your first Cocos2d-x application. The parameters used on the command line are:
-p
for package or bundle identifier-l
for language, and here, you have the optioncpp
,lua
, or JavaScript
Now let's run this app in Android.
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
- SQL Server 從入門到項目實踐(超值版)
- Getting Started with Citrix XenApp? 7.6
- OpenDaylight Cookbook
- Scala Design Patterns
- 神經網絡編程實戰:Java語言實現(原書第2版)
- Java程序員面試算法寶典
- Cassandra Data Modeling and Analysis
- 用戶體驗可視化指南
- 人人都能開發RPA機器人:UiPath從入門到實戰
- Python數據科學實踐指南
- AngularJS UI Development
- 網頁設計與制作
- C++面向對象程序設計
- 美麗洞察力:從化妝品行業看顧客需求洞察
- Android開發權威指南(第二版)