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

Method init

tests/cpp-tests/Source/UITest/CocoStudioGUITest/UIScene.cpp:38–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36UIScene::~UIScene() {}
37
38bool UIScene::init()
39{
40 if (TestCase::init())
41 {
42 _uiLayer = Layer::create();
43 addChild(_uiLayer);
44
45 _widget = dynamic_cast<Layout*>(
46 cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UITest/UITest.json"));
47 _uiLayer->addChild(_widget);
48
49 Size screenSize = Director::getInstance()->getWinSize();
50 Size rootSize = _widget->getContentSize();
51 _uiLayer->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2));
52
53 // disable these widgets because they are conflict with menu items created in `TestCase`
54
55 auto restartButton = Helper::seekWidgetByName(_widget, "middle_Button");
56 restartButton->setVisible(false);
57 restartButton->setEnabled(false);
58
59 auto leftButton = Helper::seekWidgetByName(_widget, "left_Button");
60 leftButton->setVisible(false);
61 leftButton->setEnabled(false);
62
63 auto rightButton = Helper::seekWidgetByName(_widget, "right_Button");
64 rightButton->setVisible(false);
65 rightButton->setEnabled(false);
66
67 Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
68
69 _sceneTitle = dynamic_cast<Text*>(root->getChildByName("UItest"));
70 return true;
71 }
72 return false;
73}
74
75void UIScene::onEnter()
76{

Callers

nothing calls this directly

Calls 12

createFunction · 0.85
getInstanceFunction · 0.85
widgetFromJsonFileMethod · 0.80
initFunction · 0.50
Vec2Function · 0.50
addChildMethod · 0.45
getContentSizeMethod · 0.45
setPositionMethod · 0.45
setVisibleMethod · 0.45
setEnabledMethod · 0.45
getChildByTagMethod · 0.45
getChildByNameMethod · 0.45

Tested by

no test coverage detected