Hi guys, I am making a clone of a flappy bird and I am facing this problem, my game crashes after I try to delete a sprite after animating it.
I have a SpawnPipe function that is called from GameScene when pipes need to be spawned. In this function, I registered the animation of the pipe movement and its removal after the movement, but the game crashes.
topPipe->setPosition(Point(visibleSize.width + topPipe->getContentSize().width + origin.x +
(visibleSize.width / 2), topPipePosition));
bottomPipe->setPosition(Point(topPipe->getPositionX() - topPipe->getContentSize().width * 2,
topPipePosition - (Sprite::createWithSpriteFrameName("bird1.png")->getContentSize().height *
PIPE_GAP) * cocos2d::random(1.0, 2.0) /*- topPipe->getContenSize().height*/));
layer->addChild(topPipe);
layer->addChild(bottomPipe);
auto fadeIn = FadeIn::create(0.3f);
auto topPipeAction = MoveBy::create(PIPE_MOVEMENT * visibleSize.width * 2, Point(-visibleSize.width * 3, 0));
auto bottomPipeAction = MoveBy::create(PIPE_MOVEMENT * visibleSize.width * 2, Point(-visibleSize.width * 3, 0));
auto seqTop = Sequence::create(fadeIn, topPipeAction, CallFunc::create([&topPipe, &bottomPipe, layer]()
{
layer->removeChild(topPipe, true);
}), nullptr);
auto seqBot = Sequence::create(fadeIn->clone(), bottomPipeAction, CallFunc::create([&topPipe, &bottomPipe, layer]()
{
layer->removeChild(bottomPipe, true);
}), nullptr);
topPipe->runAction(seqTop);
bottomPipe->runAction(seqBot);
Help me please)
4 posts - 4 participants
Read full topic