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

Method init

Source/GameObject.cpp:35–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33ax::Color3B _tempColor;
34
35bool GameObject::init(std::string_view frame, std::string_view glowFrame)
36{
37 if (frame.find("player") != std::string::npos)
38 return true;
39
40 if (frame.empty())
41 {
42 // GameToolbox::log("false cuz frame is empty");
43 return false;
44 }
45
46 if (!Sprite::initWithSpriteFrameName(fmt::format("{}.png", frame)))
47 {
48 // GameToolbox::log("false cuz sprite failed");
49 return false;
50 }
51
52 _pOuterBounds = Rect();
53 _pInnerBounds = Rect();
54
55 _glowSprite = nullptr;
56
57 if (!glowFrame.empty())
58 {
59 _glowSprite = Sprite::createWithSpriteFrameName(fmt::format("{}.png", glowFrame));
60 if (_glowSprite)
61 {
62 _hasGlow = true;
63 _glowSprite->setBlendFunc(GameToolbox::getBlending());
64 _glowSprite->setStretchEnabled(false);
65 _glowSprite->setLocalZOrder(-1);
66 _glowSprite->retain();
67 }
68 }
69 _texturePath = getTexture()->getPath();
70
71 setCascadeColorEnabled(false);
72 setCascadeOpacityEnabled(false);
73
74 return true;
75}
76
77void GameObject::addCustomSprites(nlohmann::json j, ax::Sprite* parent)
78{

Callers 1

createMethod · 0.45

Calls 1

emptyMethod · 0.80

Tested by

no test coverage detected