Time for action – setting up our screen resolution
The old AppDelegate
class logic now exists inside a file called main.lua
:
- In the IDE, open the
main.lua
file inside thesrc
folder. - After the line where we set the animation interval, type the following:
cc.Director:getInstance():getOpenGLView(): setDesignResolutionSize(640, 960, cc.ResolutionPolicy.SHOW_ALL) local screenSize = cc.Director:getInstance():getVisibleSize() local designSize = cc.size(640, 960) if (screenSize.width > 320) then cc.Director:getInstance():setContentScaleFactor(640/ designSize.width) cc.FileUtils:getInstance():addSearchPath("res/hd/") else cc.Director:getInstance():setContentScaleFactor(320/designSize.width) cc.FileUtils:getInstance():addSearchPath("res/sd/") end
- I designed the game for iPhone retina, and here we set the appropriate scale and asset folder for both retina and non-retina phones. Next, let's preload the sound files...