Game Development Reference
In-Depth Information
Time for action - setting up our screen
resolution
The old AppDelegate class logic now exists inside a file called main.lua :
1. In the IDE, open the main.lua file inside the src folder.
2. 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
3. I designed the game for iPhone retina, and here we set the appropriate scale and as-
set folder for both retina and non-retina phones. Next, let's preload the sound files:
local bgMusicPath =
cc.FileUtils:getInstance():fullPathForFilename("background.mp3")
cc.SimpleAudioEngine:getInstance():preloadMusic(bgMusicPath)
local effectPath =
cc.FileUtils:getInstance():fullPathForFilename("match.wav")
Search WWH ::




Custom Search