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

Method init

Source/ListLayer.cpp:46–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46bool ListLayer::init(ax::Node* scrollLayer, const char* label, ax::Color4B color, ax::Vec2 size){
47 if(!this->initWithColor(color)) return false;
48
49 const auto& winSize = ax::Director::getInstance()->getWinSize();
50
51 this->setContentSize(size);
52
53 //menu start
54 if(scrollLayer != nullptr){
55 scrollLayer->setPosition({size.x / 2, size.y / 2.0f});
56 scrollLayer->setContentSize(size);
57 this->addChild(scrollLayer);
58 }
59
60 auto bottom = ax::Sprite::createWithSpriteFrameName("GJ_table_bottom_001.png");
61 bottom->setPosition({size.x / 2, -10});
62
63
64 auto top = ax::Sprite::createWithSpriteFrameName("GJ_table_top_001.png");
65 top->setPosition({size.x / 2, size.y + 15});
66
67
68 auto left = ax::Sprite::createWithSpriteFrameName("GJ_table_side_001.png");
69 left->setPosition(this->convertToNodeSpace({-20, 0}));
70 left->setAnchorPoint({0, 0});
71 left->setScaleY(size.height / left->getContentSize().height);
72
73
74 auto right = ax::Sprite::createWithSpriteFrameName("GJ_table_side_001.png");
75 right->setPosition(this->convertToNodeSpace({size.x + 20, 0}));
76 right->setAnchorPoint({1, 0});
77 right->setScaleY(left->getScaleY());
78 right->setFlippedX(true);
79
80 this->addChild(left);
81 this->addChild(right);
82 this->addChild(top);
83 this->addChild(bottom);
84
85 auto text = ax::Label::createWithBMFont(GameToolbox::getTextureString("bigFont.fnt"), label, ax::TextHAlignment::CENTER);
86
87 text->setPositionX(top->getPositionX());
88 text->setPositionY(top->getPositionY() * 1.01);
89 text->setScale(0.8f);
90 this->addChild(text);
91
92 return true;
93}

Callers 1

createMethod · 0.45

Calls 3

setPositionMethod · 0.80
setScaleYMethod · 0.80
setScaleMethod · 0.80

Tested by

no test coverage detected