MCPcopy Create free account
hub / github.com/cocos/cocos-engine / init

Method init

native/tools/simulator/frameworks/runtime-src/Classes/Game.cpp:56–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56int Game::init() {
57
58 cc::pipeline::GlobalDSManager::setDescriptorSetLayout();
59 SimulatorApp::getInstance()->init();
60 std::call_once(_windowCreateFlag, [&]() {
61 cc::ISystemWindowInfo info;
62 info.width= SimulatorApp::getInstance()->getWidth();
63 info.height = SimulatorApp::getInstance()->getHeight();
64 #if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
65 info.x = (GetSystemMetrics(SM_CXSCREEN) - info.width) / 2;
66 info.y = (GetSystemMetrics(SM_CYSCREEN) - info.height) / 2;
67 #elif (CC_PLATFORM == CC_PLATFORM_MACOS)
68 auto mainDisplayId = CGMainDisplayID();
69 info.x = (CGDisplayPixelsWide(mainDisplayId) - info.width) / 2;
70 info.y = (CGDisplayPixelsHigh(mainDisplayId) - info.height) / 2;
71 #endif
72 info.title = "My Game";
73 info.flags = cc::ISystemWindow::CC_WINDOW_SHOWN |
74 cc::ISystemWindow::CC_WINDOW_RESIZABLE |
75 cc::ISystemWindow::CC_WINDOW_INPUT_FOCUS;
76
77 cc::ISystemWindowManager* windowMgr = CC_GET_PLATFORM_INTERFACE(cc::ISystemWindowManager);
78 windowMgr->createWindow(info);
79 });
80 SimulatorApp::getInstance()->run();
81 auto parser = ConfigParser::getInstance();
82 setDebugIpAndPort("0.0.0.0", 5086, parser->isWaitForConnect());
83
84 int ret = cc::CocosApplication::init();
85 if (ret != 0) {
86 return ret;
87 }
88
89 auto runtimeEngine = RuntimeEngine::getInstance();
90 runtimeEngine->setEventTrackingEnable(true);
91 auto jsRuntime = RuntimeJsImpl::create();
92 runtimeEngine->addRuntime(jsRuntime, kRuntimeEngineJs);
93 runtimeEngine->start();
94
95 setXXTeaKey("");
96
97 runScript("jsb-adapter/web-adapter.js");
98 runScript("main.js");
99
100 // Runtime end
101 CC_LOG_DEBUG("iShow!");
102 return 0;
103}
104
105// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
106void Game::onPause() {

Callers

nothing calls this directly

Calls 11

isWaitForConnectMethod · 0.80
addRuntimeMethod · 0.80
initMethod · 0.65
startMethod · 0.65
initFunction · 0.50
createFunction · 0.50
getWidthMethod · 0.45
getHeightMethod · 0.45
createWindowMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected