2023-02-23 21:57:30 +08:00
|
|
|
|
|
|
|
if(version() >= 504) then
|
|
|
|
collectgarbage("incremental")
|
|
|
|
else
|
|
|
|
-- avoid memory leak
|
|
|
|
collectgarbage("setpause", 100)
|
|
|
|
collectgarbage("setstepmul", 5000)
|
|
|
|
end
|
|
|
|
|
|
|
|
----------------
|
|
|
|
-- run
|
|
|
|
AX_USE_DEPRECATED_API = true
|
|
|
|
require "axmol.init"
|
|
|
|
|
|
|
|
local director = cc.Director:getInstance()
|
|
|
|
local glView = director:getOpenGLView()
|
|
|
|
if nil == glView then
|
2023-03-25 08:37:51 +08:00
|
|
|
glView = cc.GLViewImpl:createWithRect("Lua Tests", cc.rect(0,0,960,640), 1.0, true)
|
2023-02-23 21:57:30 +08:00
|
|
|
director:setOpenGLView(glView)
|
|
|
|
end
|
|
|
|
|
|
|
|
--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)
|
|
|
|
|
|
|
|
local screenSize = glView:getFrameSize()
|
|
|
|
|
|
|
|
local designSize = {width = 480, height = 320}
|
|
|
|
|
|
|
|
if screenSize.height > 320 then
|
|
|
|
local resourceSize = {width = 960, height = 640}
|
|
|
|
cc.Director:getInstance():setContentScaleFactor(resourceSize.height/designSize.height)
|
|
|
|
end
|
|
|
|
|
2023-03-25 08:37:51 +08:00
|
|
|
glView:setDesignResolutionSize(designSize.width, designSize.height, cc.ResolutionPolicy.SHOW_ALL)
|
2023-02-23 21:57:30 +08:00
|
|
|
|
|
|
|
local fileUtils = cc.FileUtils:getInstance()
|
|
|
|
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")
|
|
|
|
end
|
|
|
|
|
|
|
|
fileUtils:setSearchPaths(searchPaths)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
addSearchPath("res/", screenSize.height)
|
|
|
|
addSearchPath("", screenSize.height)
|
|
|
|
|
|
|
|
require "mainMenu"
|
|
|
|
|
|
|
|
local scene = cc.Scene:create()
|
|
|
|
scene:addChild(CreateTestMenu())
|
|
|
|
if cc.Director:getInstance():getRunningScene() then
|
|
|
|
cc.Director:getInstance():replaceScene(scene)
|
|
|
|
else
|
|
|
|
cc.Director:getInstance():runWithScene(scene)
|
|
|
|
end
|