Game Development Reference
In-Depth Information
_bomb->stopAllActions();
_bomb->setScale(0.1f);
_bomb->setPosition(tap);
_bomb->setVisible(true);
_bomb->setOpacity(50);
_bomb->runAction(_growBomb->clone());
auto child = (Sprite *)
_bomb->getChildByTag(kSpriteHalo);
child->runAction(_rotateSprite->clone());
child = (Sprite *)
_bomb->getChildByTag(kSpriteSparkle);
child->runAction(_rotateSprite->clone());
}
}
4. If
_bomb
is visible, it means it's already growing on the screen. So on touch, we
use the
stopAllActions()
method on the bomb and we use the
stopAllActions()
method on its children that we retrieve through our tags:
child = (Sprite *) _bomb->getChildByTag(kSpriteHalo);
child->stopAllActions();
child = (Sprite *)
_bomb->getChildByTag(kSpriteSparkle);
child->stopAllActions();
5. If
_bomb
is the right size, we start our
_shockwave
. If it isn't, we play a bomb
failure sound effect; there is no explosion and
_shockwave
is not made visible.
6. If we have an explosion, then the
_shockwave
sprite is set to
10
percent of the
scale. It's placed at the same spot as the bomb, and we run a couple of actions on
it: we grow the
_shockwave
sprite to twice the scale the bomb was when it
went off and we run a copy of
_shockwaveSequence
that we created earlier.
7. Finally, if no
_bomb
is currently visible on screen, we create one. And we run
clones of previously created actions on the
_bomb
sprite and its children. When
_bomb
grows, its children grow. But when the children rotate, the bomb does
not: a parent changes its children, but the children do not change their parent.