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

Method switchState

Source/GJChestSprite.cpp:45–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45bool GJChestSprite::switchState(int state, bool idk)
46{
47 this->removeAllChildren();
48 if (state == 2)
49 {
50 Sprite* chestSprite = Sprite::createWithSpriteFrameName(fmt::format("chest_0{}_0{}_001.png", _chestID, state));
51 this->addChild(chestSprite);
52 return true;
53 }
54
55 Color3B glowColor = Color3B(255, 150, 0);
56
57 switch (_chestID)
58 {
59 case 2:
60 glowColor = Color3B(0, 200, 255);
61 break;
62 case 3:
63 glowColor = Color3B(0, 200, 0);
64 break;
65 }
66
67 if (state == 3)
68 {
69 Sprite* chestSprite = Sprite::createWithSpriteFrameName(fmt::format("chest_0{}_0{}_001.png", _chestID, state));
70 Sprite* chestSpriteBack = Sprite::createWithSpriteFrameName(fmt::format("chest_0{}_0{}_back_001.png", _chestID, state));
71 Sprite* chestGlow = Sprite::createWithSpriteFrameName(fmt::format("chest_0{}_0{}_glow_001.png", _chestID, state));
72 chestGlow->setBlendFunc(GameToolbox::getBlending());
73
74 this->addChild(chestSpriteBack);
75 this->addChild(chestGlow);
76 this->addChild(chestSprite);
77
78 if (!idk)
79 {
80 auto chestOpenParticle = ParticleSystemQuad::create("chestOpen.plist");
81 chestOpenParticle->setStartColor({(float) glowColor.r, (float) glowColor.g, (float) glowColor.b, 255});
82 chestOpenParticle->setEndColor({(float) glowColor.r, (float) glowColor.g, (float) glowColor.b, 255});
83 chestOpenParticle->setPosition({0.0f, 0.0f});
84 this->addChild(chestOpenParticle);
85 }
86 return true;
87 }
88 if (state != 4) return true;
89 if (state == 4)
90 {
91 Sprite* chestSprite = Sprite::createWithSpriteFrameName(fmt::format("chest_0{}_0{}_001.png", _chestID, state));
92 Sprite* chestSpriteBack = Sprite::createWithSpriteFrameName(fmt::format("chest_0{}_0{}_back_001.png", _chestID, state));
93 Sprite* chestGlow = Sprite::createWithSpriteFrameName(fmt::format("chest_0{}_0{}_glow_001.png", _chestID, state));
94 Sprite* shineSprite1 = Sprite::createWithSpriteFrameName("shineBurst_001.png");
95 Sprite* shineSprite2 = Sprite::createWithSpriteFrameName("shineBurst_001.png");
96 chestGlow->setBlendFunc(GameToolbox::getBlending());
97 shineSprite1->setBlendFunc(GameToolbox::getBlending());
98 shineSprite1->setColor({glowColor});
99 shineSprite2->setBlendFunc(GameToolbox::getBlending());
100 shineSprite2->setColor({glowColor});
101
102 auto glow1 = EaseInOut::create(FadeTo::create(1.0,175),2.0);

Callers 3

createMethod · 0.80
initMethod · 0.80
playRewardEffectMethod · 0.80

Calls 8

Color3BClass · 0.85
createFunction · 0.85
setPositionMethod · 0.80
setScaleMethod · 0.80
setScaleXMethod · 0.80
setScaleYMethod · 0.80
setOpacityMethod · 0.80
setColorMethod · 0.45

Tested by

no test coverage detected