How to Debug Cocos Lua Game Using Cocos Code IDE

Supported Debugging Environment:

Platform Mac App Android Apk iOS App Win32 Exe
Mac OS X Yes Yes Yes No
Win32 No Yes No Yes

Let's take Mac OS X as an example, the processe are almost the same.

Prerequisite

If you haven't installed Cocos Code IDE, please read Getting Started first.

Run and Test Game

  1. Create a new Cocos Lua Project
  2. Right click the project in the Cocos Explorer
  3. In the pop-up menu, select "Debug As->Cocos Luabinding", this will create a debug configuration with your project name
  4. as default, it will run the project's lua script on the Mac prebuilt app .

How to Debug

Breakpoints

Live coding

Do you want to change the moving path on the fly? The "tick()" function in main.lua controls the spriteDog's position.

-- moving dog at every frame
local function tick()
    if spriteDog.isPaused then return end
    local x, y = spriteDog:getPosition()
    if x > origin.x + visibleSize.width then
        x = origin.x
    else
        x = x + 1
    end

    spriteDog:setPositionX(x)
end    

play around with the values, such as changing the value 1 to 10 and save your change. Wow, the spriteDog changed its moving path without restarting the app!

How to debug on other target platforms

iOS simulator

iOS devices

android devices

Enjoy!