MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / applicationDidFinishLaunching

Method applicationDidFinishLaunching

test/browser/cocos2d_hello.cpp:226–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226bool AppDelegate::applicationDidFinishLaunching() {
227 // initialize director
228 Director* director = Director::getInstance();
229 EGLView* glView = EGLView::getInstance();
230
231 director->setOpenGLView(glView);
232
233 Size size = director->getWinSize();
234
235 // Set the design resolution
236 glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
237
238 Size frameSize = glView->getFrameSize();
239
240 vector<string> searchPath;
241
242 // In this demo, we select resource according to the frame's height.
243 // If the resource size is different from design resolution size, you need to set contentScaleFactor.
244 // We use the ratio of resource's height to the height of design resolution,
245 // this can make sure that the resource's height could fit for the height of design resolution.
246
247 // if the frame's height is larger than the height of medium resource size, select large resource.
248 if (frameSize.height > mediumResource.size.height)
249 {
250 searchPath.push_back(largeResource.directory);
251
252 director->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
253 }
254 // if the frame's height is larger than the height of small resource size, select medium resource.
255 else if (frameSize.height > smallResource.size.height)
256 {
257 searchPath.push_back(mediumResource.directory);
258
259 director->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
260 }
261 // if the frame's height is smaller than the height of medium resource size, select small resource.
262 else
263 {
264 searchPath.push_back(smallResource.directory);
265
266 director->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
267 }
268
269 // set searching path
270 FileUtils::getInstance()->setSearchPaths(searchPath);
271
272 // turn on display FPS
273 director->setDisplayStats(false);
274
275 // set FPS. the default value is 1.0/60 if you don't call this
276 director->setAnimationInterval(1.0 / 60);
277
278 // create a scene. it's an autorelease object
279 Scene *scene = HelloWorld::scene();
280
281 // run
282 director->runWithScene(scene);
283

Callers

nothing calls this directly

Calls 1

push_backMethod · 0.65

Tested by

no test coverage detected