function __G__TRACKBACK__(errorMessage)
print("----------------------------------------")
print("LUA ERROR: " .. tostring(errorMessage) .. "\n")
print(debug.traceback("", 2))
print("----------------------------------------")
end
require("config") -- 加载config
require("framework.init") -- 加载quick提供的简化开发流程的lua脚本
require("framework.shortcodes") -- quick提供了一组名字较短的函数,封装了cocos的冗长名称。简化开发
require("framework.cc.init") -- 加载ui,事件,app等脚本
local MyApp = class("MyApp", cc.mvc.AppBase)
function MyApp:ctor()
MyApp.super.ctor(self)
end
function MyApp:run()
CCFileUtils:sharedFileUtils():addSearchPath("res/")
self:enterScene("MainScene")
end
return MyApp
function MainScene:ctor()
ui.newTTFLabel({text = "Hello, World", size = 64, align = ui.TEXT_ALIGN_CENTER})
:pos(display.cx, display.cy)
:addTo(self)
end
function MainScene:onEnter()
if device.platform == "android" then
-- avoid unmeant back
self:performWithDelay(function()
-- keypad layer, for android
local layer = display.newLayer()
layer:addKeypadEventListener(function(event)
if event == "back" then app.exit() end
end)
self:addChild(layer)
layer:setKeypadEnabled(true)
end, 0.5)
end
end
function MainScene:onExit()
end
return MainScene