Lua Engine Support
Cocos Creator developers that use Lua can build scenes and UI, and use Lua script to control nodes and UIs in game.
Currently supported features:
Sprite- Sprite image renderer
Canvas- Mainly used for responsive multi-resolution design
Widget- You can set up automatic alignment with responsive Canvas or elements
Button- Response to player interaction
EditBox- For players to enter text
ParticleSystem- Renderer for particle effects
TileMap- Renderer for map generated by Tiled Map Editor
Animation- Currently only sprite animation supported
Label (System Font)- Currently only system font supported
Component with Lifetime events- Components and life cycle management
Instructions for use
There are three steps needed to use scenes created by Cocos Creator in Lua project. This will be further streamlined in coming versions.
First you need to download the latest version of the Creator-Lua template project.
Or you can pull from GitHub:
sh $ git clone https://github.com/dualface/creator-lua.git
For the rest of this document we refer to this as PATH-TO-CREATOR-LUA.
Create a new project Lua:
sh cocos new -l lua GAME-NAME
Remove Lua Project
resdirectory of all files.
Copy the PATH-TO-CREATOR-LUA/lua-project/src files and all subdirectories in the directory to src Lua project.
Copy the PATH-TO-CREATOR-LUA /lua-project/convert-creator-build.sh and PATH-TO-CREATOR-LUA /lua-project/convert-creator-build.bat project file to the Lua directory.
Building A Scene
- In Cocos Creator, save the edited scenes, and then select the menu Project -> Build publish.
Publish the platform of choice for the Lua
Click the Build button
After completion the publishing path will contain all the scenes and their resources. These resources can not be used in a Lua project without being converted.
Converting to Lua format
- From the command-line goto the Lua project directory.
- If you are on OSX or Linux, run ./convert-creator-build.sh ../creator-project/build/lua. If you are on Windows, run convert-creator-build.bat .. \creator-project\build\lua.
- You will see done if everything converts successfully.
After the conversion is complete, open the operation of the project (or use
cocos run command),
you can see the effect of the scene:
After every change made to the Scene you need to do build -> Convert operation.