MCPcopy Create free account
hub / github.com/axmolengine/axmol / init

Method init

tests/live2d-tests/Source/SampleScene.cpp:46–150  ·  view source on GitHub ↗

on "init" you need to initialize your instance

Source from the content-addressed store, hash-verified

44
45// on "init" you need to initialize your instance
46bool SampleScene::init()
47{
48 //////////////////////////////
49 // 1. super init first
50 if (!Scene::init())
51 {
52 return false;
53 }
54
55 // Live2DManager実体化の前に必要となる
56 instance = this;
57
58 auto winSize = Director::getInstance()->getWinSize();
59 auto visibleSize = Director::getInstance()->getVisibleSize();
60 Vec2 origin = Director::getInstance()->getVisibleOrigin();
61
62 /////////////////////////////
63 // 2. add a menu item with "X" image, which is clicked to quit the program
64 // you may modify it.
65
66 // add a "close" icon to exit the progress. it's an autorelease object
67 _closeItem = MenuItemImage::create(
68 "CloseNormal.png",
69 "CloseSelected.png",
70 AX_CALLBACK_1(SampleScene::menuCloseCallback, this)
71 );
72
73 if (_closeItem == nullptr ||
74 _closeItem->getContentSize().width <= 0 ||
75 _closeItem->getContentSize().height <= 0)
76 {
77 problemLoading("'CloseNormal.png' and 'CloseSelected.png'");
78 }
79
80 // create menu, it's an autorelease object
81 auto closeMenu = Menu::create(_closeItem, NULL);
82 closeMenu->setScale(0.9f);
83 closeMenu->setPosition(Vec2::ZERO);
84 this->addChild(closeMenu, 1);
85
86 _changeItem = MenuItemImage::create(
87 "icon_gear.png",
88 "icon_gear.png",
89 AX_CALLBACK_1(SampleScene::menuChangeCallback, this)
90 );
91
92 if (_changeItem == nullptr ||
93 _changeItem->getContentSize().width <= 0 ||
94 _changeItem->getContentSize().height <= 0)
95 {
96 problemLoading("'icon_gear.png'");
97 }
98
99 // create menu, it's an autorelease object
100 auto changeMenu = Menu::create(_changeItem, NULL);
101 changeMenu->setScale(0.9f);
102 changeMenu->setPosition(Point::ZERO);
103 this->addChild(changeMenu, 1);

Callers 1

createDrawNodeMethod · 0.45

Calls 13

getInstanceFunction · 0.85
createFunction · 0.85
setDebugRectsNodeMethod · 0.80
scheduleUpdateMethod · 0.80
problemLoadingFunction · 0.70
initFunction · 0.50
Vec2Function · 0.50
getVisibleSizeMethod · 0.45
getVisibleOriginMethod · 0.45
getContentSizeMethod · 0.45
setScaleMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected