| 33 | ax::Color3B _tempColor; |
| 34 | |
| 35 | bool 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 | |
| 77 | void GameObject::addCustomSprites(nlohmann::json j, ax::Sprite* parent) |
| 78 | { |