| 52 | } |
| 53 | |
| 54 | bool CircleWave::init(float duration, Color4B color, float radiusMin, float radiusMax, bool easing, float lineWidth, bool filled) |
| 55 | { |
| 56 | if (!DrawNode::init()) return false; |
| 57 | |
| 58 | this->setColor(color); |
| 59 | this->_radius = radiusMin; |
| 60 | this->_lineWidth = lineWidth; |
| 61 | this->_filled = filled; |
| 62 | |
| 63 | if (easing) |
| 64 | { |
| 65 | this->_color.a = 0; |
| 66 | auto radAction = ActionTween::create(duration, "radius", radiusMin, radiusMax); |
| 67 | auto opacityAction = ActionTween::create(duration / 2, "opacity", 0.0, 1.0); |
| 68 | auto opacityAction2 = ActionTween::create(duration / 2, "opacity", 1.0, 0.0); |
| 69 | auto seq = Sequence::create(opacityAction, opacityAction2, CallFunc::create([&]() { |
| 70 | this->removeFromParent(); |
| 71 | }), nullptr); |
| 72 | auto action = Spawn::create(radAction, seq, nullptr); |
| 73 | Director::getInstance()->getActionManager()->addAction(action, this, false); |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | auto radAction = EaseOut::create(ActionTween::create(duration, "radius", radiusMin, radiusMax), 2.0f); |
| 78 | auto opacityAction = EaseOut::create(ActionTween::create(duration / 2, "opacity", this->_color.a, 0.0), 2.0f); |
| 79 | auto spawn = Spawn::create(radAction, opacityAction, nullptr); |
| 80 | auto action = Sequence::create(spawn, CallFunc::create([&](){ this->removeFromParent();}), nullptr); |
| 81 | Director::getInstance()->getActionManager()->addAction(action, this, false); |
| 82 | } |
| 83 | |
| 84 | this->scheduleUpdate(); |
| 85 | |
| 86 | return true; |
| 87 | } |
| 88 | |
| 89 | void CircleWave::updateTweenAction(float value, std::string_view key) |
| 90 | { |