2014-07-14 13:58:21 +08:00
|
|
|
|
2014-03-11 16:52:06 +08:00
|
|
|
require "Cocos2d"
|
2014-08-04 17:11:57 +08:00
|
|
|
require "extern"
|
2014-03-26 19:42:07 +08:00
|
|
|
|
2014-03-11 16:52:06 +08:00
|
|
|
-- cclog
|
2014-07-16 20:49:24 +08:00
|
|
|
local cclog = function(...)
|
2014-03-11 16:52:06 +08:00
|
|
|
print(string.format(...))
|
|
|
|
end
|
|
|
|
|
|
|
|
-- for CCLuaEngine traceback
|
|
|
|
function __G__TRACKBACK__(msg)
|
|
|
|
cclog("----------------------------------------")
|
|
|
|
cclog("LUA ERROR: " .. tostring(msg) .. "\n")
|
|
|
|
cclog(debug.traceback())
|
|
|
|
cclog("----------------------------------------")
|
2014-04-25 19:42:31 +08:00
|
|
|
return msg
|
2014-03-11 16:52:06 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function main()
|
|
|
|
collectgarbage("collect")
|
|
|
|
-- avoid memory leak
|
|
|
|
collectgarbage("setpause", 100)
|
|
|
|
collectgarbage("setstepmul", 5000)
|
2014-09-16 16:19:05 +08:00
|
|
|
|
|
|
|
-- 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)
|
2014-07-14 13:58:21 +08:00
|
|
|
|
|
|
|
cc.FileUtils:getInstance():addSearchPath("src")
|
|
|
|
cc.FileUtils:getInstance():addSearchPath("res")
|
2014-05-05 21:04:04 +08:00
|
|
|
cc.Director:getInstance():getOpenGLView():setDesignResolutionSize(480, 320, 0)
|
2014-07-14 13:58:21 +08:00
|
|
|
|
|
|
|
--create scene
|
2014-07-16 21:20:48 +08:00
|
|
|
local scene = require("GameScene")
|
2014-07-16 22:36:47 +08:00
|
|
|
local gameScene = scene.create()
|
|
|
|
gameScene:playBgMusic()
|
2014-07-14 13:58:21 +08:00
|
|
|
|
2014-07-15 15:07:01 +08:00
|
|
|
if cc.Director:getInstance():getRunningScene() then
|
2014-07-16 22:36:47 +08:00
|
|
|
cc.Director:getInstance():replaceScene(gameScene)
|
2014-07-15 15:07:01 +08:00
|
|
|
else
|
2014-07-16 22:36:47 +08:00
|
|
|
cc.Director:getInstance():runWithScene(gameScene)
|
2014-07-15 15:07:01 +08:00
|
|
|
end
|
2014-03-11 16:52:06 +08:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-04-25 19:42:31 +08:00
|
|
|
local status, msg = xpcall(main, __G__TRACKBACK__)
|
|
|
|
if not status then
|
|
|
|
error(msg)
|
|
|
|
end
|