diff --git a/tests/lua-empty-test/project/Classes/AppDelegate.cpp b/tests/lua-empty-test/project/Classes/AppDelegate.cpp index ce16e51490..8b650561ab 100644 --- a/tests/lua-empty-test/project/Classes/AppDelegate.cpp +++ b/tests/lua-empty-test/project/Classes/AppDelegate.cpp @@ -22,24 +22,6 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { - // initialize director - auto director = Director::getInstance(); - auto glview = director->getOpenGLView(); - if(!glview) { - glview = GLView::create("Lua Empty Test"); - director->setOpenGLView(glview); - } - - director->setOpenGLView(glview); - - glview->setDesignResolutionSize(480, 320, ResolutionPolicy::NO_BORDER); - - // 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); - // register lua engine LuaEngine* engine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); diff --git a/tests/lua-empty-test/src/hello.lua b/tests/lua-empty-test/src/hello.lua index df80dd04da..d9ab1b2a8d 100644 --- a/tests/lua-empty-test/src/hello.lua +++ b/tests/lua-empty-test/src/hello.lua @@ -14,11 +14,32 @@ function __G__TRACKBACK__(msg) cclog("----------------------------------------") end +local function initGLView() + local director = cc.Director:getInstance() + local glView = director:getOpenGLView() + if nil == glView then + glView = cc.GLView:create("Lua Empty Test") + director:setOpenGLView(glView) + end + + director:setOpenGLView(glView) + + glView:setDesignResolutionSize(480, 320, cc.ResolutionPolicy.NO_BORDER) + + --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) +end + local function main() -- avoid memory leak collectgarbage("setpause", 100) collectgarbage("setstepmul", 5000) + initGLView() + --support debug,when used on ios7.1 64bit,these codes should be commented local targetPlatform = cc.Application:getInstance():getTargetPlatform() if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or @@ -58,7 +79,7 @@ local function main() ]]-- local animation = cc.Animation:createWithSpriteFrames({frame0,frame1}, 0.5) - local animate = cc.Animate:create(animation); + local animate = cc.Animate:create(animation) spriteDog:runAction(cc.RepeatForever:create(animate)) -- moving dog at every frame @@ -101,7 +122,7 @@ local function main() local frameCrop = cc.SpriteFrame:create("res/crop.png", cc.rect(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do - local spriteCrop = cc.Sprite:createWithSpriteFrame(frameCrop); + local spriteCrop = cc.Sprite:createWithSpriteFrame(frameCrop) spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) layerFarm:addChild(spriteCrop) end diff --git a/tests/lua-game-controller-test/project/Classes/AppDelegate.cpp b/tests/lua-game-controller-test/project/Classes/AppDelegate.cpp index 2dbebed899..ca92bd541c 100644 --- a/tests/lua-game-controller-test/project/Classes/AppDelegate.cpp +++ b/tests/lua-game-controller-test/project/Classes/AppDelegate.cpp @@ -24,16 +24,6 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { - - auto director = Director::getInstance(); - auto glview = director->getOpenGLView(); - if(!glview) { - glview = GLView::create("Lua Game Controller Test"); - director->setOpenGLView(glview); - } - - director->setOpenGLView(glview); - LuaEngine* engine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); LuaStack* stack = engine->getLuaStack(); diff --git a/tests/lua-game-controller-test/src/main.lua b/tests/lua-game-controller-test/src/main.lua index 77956e5c79..cdc55801c3 100644 --- a/tests/lua-game-controller-test/src/main.lua +++ b/tests/lua-game-controller-test/src/main.lua @@ -16,10 +16,18 @@ local largeResource = directory = "ipadhd", } -local glView = cc.Director:getInstance():getOpenGLView() +local director = cc.Director:getInstance() +local glView = director:getOpenGLView() +if nil == glView then + glView = cc.GLView:create("Game Controller Test") + director:setOpenGLView(glView) +end + +director:setOpenGLView(glView) + local designResolutionSize = cc.size(1920, 1080) -glView:setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, 2) +glView:setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, cc.ResolutionPolicy.SHOW_ALL) local frameSize = glView:getFrameSize() diff --git a/tests/lua-tests/project/Classes/AppDelegate.cpp b/tests/lua-tests/project/Classes/AppDelegate.cpp index 3bad5648b8..ce312026d4 100644 --- a/tests/lua-tests/project/Classes/AppDelegate.cpp +++ b/tests/lua-tests/project/Classes/AppDelegate.cpp @@ -19,31 +19,6 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { - auto director = Director::getInstance(); - auto glview = director->getOpenGLView(); - if(!glview) { - glview = GLView::createWithRect("Lua Tests", Rect(0,0,900,640)); - director->setOpenGLView(glview); - } - - // 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); - - auto screenSize = glview->getFrameSize(); - - auto designSize = Size(480, 320); - - if (screenSize.height > 320) - { - auto resourceSize = Size(960, 640); - director->setContentScaleFactor(resourceSize.height/designSize.height); - } - - glview->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::FIXED_HEIGHT); - // register lua engine LuaEngine* pEngine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); diff --git a/tests/lua-tests/src/controller.lua b/tests/lua-tests/src/controller.lua index 02aa9ca067..1b5e02dbaf 100644 --- a/tests/lua-tests/src/controller.lua +++ b/tests/lua-tests/src/controller.lua @@ -6,25 +6,30 @@ collectgarbage("setstepmul", 5000) ---------------- -- run +local director = cc.Director:getInstance() +local glView = director:getOpenGLView() +if nil == glView then + glView = cc.GLView:createWithRect("Lua Tests", cc.Rect(0,0,900,640)) +end -local glView = cc.Director:getInstance():getOpenGLView() +--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} -local fileUtils = cc.FileUtils:getInstance() - - -local targetPlatform = cc.Application:getInstance():getTargetPlatform() - -local dd = glView:getDesignResolutionSize() if screenSize.height > 320 then local resourceSize = {width = 960, height = 640} - local rate = resourceSize.height/screenSize.height - cc.Director:getInstance():setContentScaleFactor(resourceSize.height/designSize.height); + cc.Director:getInstance():setContentScaleFactor(resourceSize.height/designSize.height) end -glView:setDesignResolutionSize(designSize.width, designSize.height, 3); - + +glView:setDesignResolutionSize(designSize.width, designSize.height, cc.ResolutionPolicy.FIXED_HEIGHT) + +local fileUtils = cc.FileUtils:getInstance() local function addSearchPath(resPrefix, height) local searchPaths = fileUtils:getSearchPaths() table.insert(searchPaths, 1, resPrefix)