Remove sprite and animation

Vector<SpriteFrame*> frames(7);
        SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Anim/data.plist");

        auto animSpr = Sprite::create("Anim/a1.png");
        for (int i = 1; i <= 7; i++) {
            auto frame = String::createWithFormat("a%d.png", i);
            frames.pushBack(
                SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(
                frame->getCString()));
        }

        Animation* anim = Animation::createWithSpriteFrames(frames, 0.05f);
        animSpr->setScale(2);
        animSpr->setPosition(Point((visibleSize.width + origin.x) / 2, (visibleSize.height + origin.y) * 5 / 100) );
        this->addChild(animSpr, 68);
       animSpr->runAction(Animate::create(anim));

I tried RemoveSelf and removeFromParentAndCleanup but the initial sprite and the last sprite of animation remains on the screen after animation being played. How to remove them?

You do only need to remove the sprite.

auto removeSelf = RemoveSelf::create();
auto animate = Animate::create(anim);
animSpr->runAction(Sequence::create(animate, removeSelf, nullptr));

I tried but the initial sprite and the last sprite of the animation remains on the screen after removing.

auto removeSelf = RemoveSelf::create();
auto wait = DelayTime::create(0.35f);
auto anim = Animate::create(anim);
animSpr->runAction(Sequence::create(anim, wait, removeSelf, NULL));//kolay gelsin :)

@Onurtnrkl thank you very much it works now!
p.s: // kanka çaktırma seninki de çalışmadı ama ecnebiler bizi güçlü bilsin :smiley:

There’s a bug in the engine somewhere if you need a delay. I’ve never had the need to delay, so it’s curious or odd that it left visuals on the screen.