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

Method initWithText

Source/ButtonSprite.cpp:67–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67bool ButtonSprite::initWithText(std::string_view caption, int width, int minWidth, float scale, bool absoluteWidth, std::string_view font, std::string_view texture, float height)
68{
69 if (!Sprite::init())
70 return false;
71
72 _hasTextProvided = true;
73 _scale = scale;
74 _width = static_cast<float>(width);
75 _absoluteWidth = absoluteWidth;
76 _height = height;
77 _minWidth = static_cast<float>(minWidth);
78
79 _spriteOffset = { 0, 2 };
80
81 if (font == GameToolbox::getTextureString("bigFont.fnt"))
82 _spriteOffset = { -1, 2 };
83
84 _label = ax::Label::createWithBMFont(font, "");
85 this->addChild(_label, 1);
86
87 _buttonTexture = ui::Scale9Sprite::create(texture, ax::Rect(0, 0, 40, 40));
88 _buttonTexture->setContentSize({ 16, 16 });
89 this->addChild(_buttonTexture, 0);
90
91 this->setString(caption);
92
93 return true;
94}
95
96bool ButtonSprite::initWithSprite(Sprite* iconSprite, int width, int minWidth, float height, float scale, bool absoluteWidth, std::string_view texture, bool dontUseScale9)
97{

Callers 1

createMethod · 0.80

Calls 2

setStringMethod · 0.95
createFunction · 0.85

Tested by

no test coverage detected