mirror of https://github.com/axmolengine/axmol.git
56 lines
1.4 KiB
Lua
56 lines
1.4 KiB
Lua
|
|
require "Cocos2d"
|
|
require "extern"
|
|
|
|
-- cclog
|
|
local cclog = function(...)
|
|
print(string.format(...))
|
|
end
|
|
|
|
-- for CCLuaEngine traceback
|
|
function __G__TRACKBACK__(msg)
|
|
cclog("----------------------------------------")
|
|
cclog("LUA ERROR: " .. tostring(msg) .. "\n")
|
|
cclog(debug.traceback())
|
|
cclog("----------------------------------------")
|
|
return msg
|
|
end
|
|
|
|
local function main()
|
|
collectgarbage("collect")
|
|
-- avoid memory leak
|
|
collectgarbage("setpause", 100)
|
|
collectgarbage("setstepmul", 5000)
|
|
|
|
-- initialize director
|
|
local director = cc.Director:getInstance()
|
|
|
|
--turn on display FPS
|
|
director:setDisplayStats(true)
|
|
|
|
--set FPS. the default value is 1.0/60 if you don't call this
|
|
director:setAnimationInterval(1.0 / 60)
|
|
|
|
cc.FileUtils:getInstance():addSearchPath("src")
|
|
cc.FileUtils:getInstance():addSearchPath("res")
|
|
cc.Director:getInstance():getOpenGLView():setDesignResolutionSize(480, 320, 0)
|
|
|
|
--create scene
|
|
local scene = require("GameScene")
|
|
local gameScene = scene.create()
|
|
gameScene:playBgMusic()
|
|
|
|
if cc.Director:getInstance():getRunningScene() then
|
|
cc.Director:getInstance():replaceScene(gameScene)
|
|
else
|
|
cc.Director:getInstance():runWithScene(gameScene)
|
|
end
|
|
|
|
end
|
|
|
|
|
|
local status, msg = xpcall(main, __G__TRACKBACK__)
|
|
if not status then
|
|
error(msg)
|
|
end
|