MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / init

Method init

Source/LevelEditorLayer.cpp:405–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405bool LevelEditorLayer::init(GJGameLevel* level) {
406 if (level->_levelString.empty() && level->_levelID > 22) {
407 level->_levelString = "H4sIAAAAAAAAC62Nyw2EMAxEGzKSx4khiBM1UMAUQAtb_JLMHnclpOUyz_Hn5TxKM7A6g4hkYWQSEEJQs3ICZ8LduRBE9mh0NuIFDoXHPQX-V6xfFX1HB7ckwX7_gCifEs0_RHbuKOYdKcxCtStVL-p80DqOso5XjJRgDPY6UlO4APMNBgu7Pik2Ibc3_hvk2yICAAA=";
408 }
409
410 if (!PlayLayer::init(level))
411 return false;
412
413 // DrawGridLayer::create();
414 // LevelTools::getInstance()->getAudioString();
415 // DrawGridLayer::getInstance()->loadTimeMarkers();
416
417 auto grid = ax::DrawNode::create();
418 addChild(grid, 10000000);
419
420 int max_block_x = (m_lastObjXPos / 30.f) + 10;
421 int max_block_y = 18;
422
423 if (max_block_x <= 29) max_block_x = 256;
424
425 int i = 0;
426
427 auto calculate_pos = [&](int x, int y) {
428 ax::Vec2 pos;
429
430 pos.x = x * 30;
431 pos.y = y * 30;
432
433 pos.y += 90;
434
435 return pos;
436 };
437
438 while (i < max_block_x) {
439 int j = 0;
440
441 while (j < max_block_y) {
442 ax::Vec2 pos = calculate_pos(i, j);
443 ax::Vec2 pos2 = pos;
444
445 pos2.x += 30;
446 pos2.y += 30;
447
448 grid->drawRect(pos, pos2, ax::Color4F::BLACK);
449
450 j++;
451 }
452
453 i++;
454 }
455
456 grid->setOpacity(128);
457
458 _bottomGround->removeFromParentAndCleanup(false);
459
460 addChild(_bottomGround, 101);
461
462 m_pHudLayer->setLocalZOrder(grid->getLocalZOrder() + 2);

Callers 1

createMethod · 0.45

Calls 8

updateCameraMethod · 0.95
createFunction · 0.85
emptyMethod · 0.80
setOpacityMethod · 0.80
setPositionMethod · 0.80
getIDMethod · 0.80
setActiveMethod · 0.80
setScaleMethod · 0.80

Tested by

no test coverage detected