2014-03-10 15:32:48 +08:00
|
|
|
|
|
|
|
-- avoid memory leak
|
|
|
|
collectgarbage("setpause", 100)
|
|
|
|
collectgarbage("setstepmul", 5000)
|
2014-06-06 11:42:18 +08:00
|
|
|
|
2014-06-20 11:09:26 +08:00
|
|
|
----------------
|
2014-03-10 15:32:48 +08:00
|
|
|
-- run
|
2014-07-11 15:34:56 +08:00
|
|
|
local director = cc.Director:getInstance()
|
|
|
|
local glView = director:getOpenGLView()
|
|
|
|
if nil == glView then
|
2014-07-31 00:53:04 +08:00
|
|
|
glView = cc.GLViewImpl:createWithRect("Lua Tests", cc.rect(0,0,900,640))
|
2014-07-11 18:13:08 +08:00
|
|
|
director:setOpenGLView(glView)
|
2014-07-11 15:34:56 +08:00
|
|
|
end
|
2014-05-22 14:00:39 +08:00
|
|
|
|
2014-07-11 15:34:56 +08:00
|
|
|
--turn on display FPS
|
|
|
|
director:setDisplayStats(true)
|
2014-05-22 14:00:39 +08:00
|
|
|
|
2014-07-11 15:34:56 +08:00
|
|
|
--set FPS. the default value is 1.0/60 if you don't call this
|
|
|
|
director:setAnimationInterval(1.0 / 60)
|
2014-05-22 14:00:39 +08:00
|
|
|
|
2014-07-11 15:34:56 +08:00
|
|
|
local screenSize = glView:getFrameSize()
|
2014-05-22 14:00:39 +08:00
|
|
|
|
2014-07-11 15:34:56 +08:00
|
|
|
local designSize = {width = 480, height = 320}
|
2014-05-22 14:00:39 +08:00
|
|
|
|
2014-06-06 11:42:18 +08:00
|
|
|
if screenSize.height > 320 then
|
2014-06-20 11:09:26 +08:00
|
|
|
local resourceSize = {width = 960, height = 640}
|
2014-07-11 15:34:56 +08:00
|
|
|
cc.Director:getInstance():setContentScaleFactor(resourceSize.height/designSize.height)
|
2014-06-06 11:42:18 +08:00
|
|
|
end
|
2014-07-11 15:34:56 +08:00
|
|
|
|
|
|
|
glView:setDesignResolutionSize(designSize.width, designSize.height, cc.ResolutionPolicy.FIXED_HEIGHT)
|
|
|
|
|
|
|
|
local fileUtils = cc.FileUtils:getInstance()
|
2014-06-20 11:09:26 +08:00
|
|
|
local function addSearchPath(resPrefix, height)
|
|
|
|
local searchPaths = fileUtils:getSearchPaths()
|
|
|
|
table.insert(searchPaths, 1, resPrefix)
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "cocosbuilderRes")
|
|
|
|
|
|
|
|
if screenSize.height > 320 then
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "hd")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/Images")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ArmatureComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/AttributeComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/BackgroundComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/EffectComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ParticleComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/SpriteComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TmxMapComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/UIComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TriggerTest")
|
|
|
|
else
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/Images")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ArmatureComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/AttributeComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/BackgroundComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/EffectComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/LoadSceneEdtiorFileTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ParticleComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/SpriteComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TmxMapComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/UIComponentTest")
|
|
|
|
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TriggerTest")
|
|
|
|
end
|
2014-05-22 14:00:39 +08:00
|
|
|
|
2014-06-20 11:09:26 +08:00
|
|
|
fileUtils:setSearchPaths(searchPaths)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
addSearchPath("res/", screenSize.height)
|
|
|
|
addSearchPath("", screenSize.height)
|
|
|
|
|
|
|
|
require "src/mainMenu"
|
2014-05-22 14:00:39 +08:00
|
|
|
|
2014-03-10 15:32:48 +08:00
|
|
|
local scene = cc.Scene:create()
|
|
|
|
scene:addChild(CreateTestMenu())
|
2014-05-23 10:00:59 +08:00
|
|
|
if cc.Director:getInstance():getRunningScene() then
|
|
|
|
cc.Director:getInstance():replaceScene(scene)
|
|
|
|
else
|
|
|
|
cc.Director:getInstance():runWithScene(scene)
|
|
|
|
end
|