| 75 | } |
| 76 | |
| 77 | void GameObject::addCustomSprites(nlohmann::json j, ax::Sprite* parent) |
| 78 | { |
| 79 | for (nlohmann::json jsonObj : j) |
| 80 | { |
| 81 | ax::Sprite* s = ax::Sprite::createWithSpriteFrameName(jsonObj["texture_name"].get<std::string>()); |
| 82 | if (!s) |
| 83 | continue; |
| 84 | parent->addChild(s); |
| 85 | s->setStretchEnabled(false); |
| 86 | s->setAnchorPoint({static_cast<float>(jsonObj["anchor_x"]), static_cast<float>(jsonObj["anchor_y"])}); |
| 87 | s->setFlippedX(static_cast<bool>(jsonObj["flip_x"])); |
| 88 | s->setFlippedY(static_cast<bool>(jsonObj["flip_y"])); |
| 89 | s->setPosition({static_cast<float>(jsonObj["x"]), static_cast<float>(jsonObj["y"])}); |
| 90 | s->setLocalZOrder(static_cast<int>(jsonObj["z"])); |
| 91 | s->setRotation(static_cast<float>(jsonObj["rot"])); |
| 92 | s->setScaleX(static_cast<float>(jsonObj["scale_x"])); |
| 93 | s->setScaleY(static_cast<float>(jsonObj["scale_y"])); |
| 94 | if (jsonObj.contains("content_x")) |
| 95 | s->setContentSize({static_cast<float>(jsonObj["content_x"]), static_cast<float>(jsonObj["content_y"])}); |
| 96 | s->setCascadeColorEnabled(false); |
| 97 | s->setCascadeOpacityEnabled(false); |
| 98 | if (jsonObj.contains("color_channel")) |
| 99 | { |
| 100 | if (jsonObj["color_channel"] == "base") |
| 101 | _childSpritesChannel.push_back(0); |
| 102 | else if (jsonObj["color_channel"] == "detail") |
| 103 | _childSpritesChannel.push_back(1); |
| 104 | else if (jsonObj["color_channel"] == "black") |
| 105 | _childSpritesChannel.push_back(2); |
| 106 | } |
| 107 | else |
| 108 | _childSpritesChannel.push_back(404); |
| 109 | |
| 110 | _childSprites.push_back(s); |
| 111 | |
| 112 | if (jsonObj.contains("children")) |
| 113 | addCustomSprites(jsonObj["children"], s); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | void GameObject::customSetup() |
| 118 | { |
nothing calls this directly
no test coverage detected