-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathmain.lua
44 lines (35 loc) · 1.12 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require "Cocos2d"
-- 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)
cc.FileUtils:getInstance():addSearchPath("src")
cc.FileUtils:getInstance():addSearchPath("res")
cc.Director:getInstance():getOpenGLView():setDesignResolutionSize(480, 800, 0)
--create scene
local scene = require("MenuScene")
local menuScene = scene.createScene()
cc.Director:getInstance():setDisplayStats(false)
if cc.Director:getInstance():getRunningScene() then
cc.Director:getInstance():replaceScene(menuScene)
else
cc.Director:getInstance():runWithScene(menuScene)
end
end
local status, msg = xpcall(main, __G__TRACKBACK__)
if not status then
error(msg)
end