Use of Cocos2d-x scripting language Lua

Source: Internet
Author: User

Use of Cocos2d-x scripting language Lua
The previous blog has introduced the basic knowledge of Lua, this blog will introduce how to use the Lua script language in the Cocos2d-x project for development. Since I use the Mac system, so the demo for everyone to run our Cocos2d-x project in XCode.
Introduce the development environment of the author:

  • Cocos2d-x 3.1.1 the latest version is Cocos2d-x 3.2alpha0, readers can go to http://www.cocos2d-x.org/downloaddownload the latest version
  • Python 3.4.0
  • Xcode 5.1.1
  • LDT (Lua Development Tools)

First use the terminal to enter the Directory:/Volumes/DATA/cocos2d-x-3.1.1/tools/cocos2d-console/bin and use cocos to create a project:

Run the command

Cocos. py new HelloCC-p com. wwj. hellocc-l lua-d ~ /Cocos2dxProj


Cocos2d-x 3. x and above use the cocos command to create a project, the command here means: Use the cocos. py script to upload a Lua project named HelloCC in the Cocos2dxProj folder under the root directory.

We can see that the HelloCC project structure, compared with the 2.x. x version, has undergone a huge change, and our corresponding platform project is here:
Open proj. ios_mac:
Double-click HelloCC. xcodeproj and use Xcode to open the project and compile and run the project. The shortcut key can be command + R:


Successful Lua projects:


Then use LDT to switch the workspace to HelloCC:

After switching the workspace, create a Lua project named src to include the Lua file in src in the Cocos2d-x, as shown in:

In this way, we can use LDT to write our Lua code.

The content of this blog has been completed, and the operation in Windows is similar. I will not talk about it here. The next blog will show you how to use Lua to develop a small game.

Related Article

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.