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

Function searchButton

Source/LevelSearchLayer.cpp:54–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53
54Sprite* searchButton(std::string texture, std::string text, float scale, std::string icon)
55{
56 auto sprite = Sprite::createWithSpriteFrameName(texture);
57 auto menu = Menu::create();
58
59 const auto& content_size = sprite->getContentSize();
60 auto label = Label::createWithBMFont(GameToolbox::getTextureString("bigFont.fnt"), text);
61 label->setScale(scale);
62 menu->addChild(label);
63
64 if (!icon.empty())
65 {
66 auto icon_sprite = Sprite::createWithSpriteFrameName(icon);
67 icon_sprite->setScale(1.1f);
68 menu->addChild(icon_sprite);
69 }
70
71 menu->setPosition(content_size / 2);
72 menu->alignItemsHorizontally();
73
74 sprite->addChild(menu);
75
76 return sprite;
77}
78
79Scene* LevelSearchLayer::scene()
80{

Callers 1

initMethod · 0.85

Calls 5

createFunction · 0.85
setScaleMethod · 0.80
emptyMethod · 0.80
setPositionMethod · 0.80

Tested by

no test coverage detected