Exemplo n.º 1
0
void GameLevel::dieImpl() {
  mDieFlag = false;

  pause();

  // Camera effect.
  getGameLayer()->getBlockRoot()->runAction(CameraShake::create(0.3f, 10));

  auto hero = getHero();

  // Particle effect.
  ParticleSystem *ps = ParticleSystemQuad::create(DIE_FX_NAME);
  ParticleBatchNode *batch = ParticleBatchNode::createWithTexture(ps->getTexture());
  batch->addChild(ps);
  batch->setPosition(hero->getRenderer()->getPosition());
  batch->setCameraMask((unsigned short) CameraFlag::USER2);
  mGameLayer->getBlockRoot()->addChild(batch, ZORDER_DIE_FX, DIE_FX_TAG);

  hero->getRenderer()->getNode()->runAction(Sequence::create(ScaleTo::create(0.2, 0.1, 0.1),
                                                             CallFunc::create([this] {
    getHero()->getRenderer()->setVisible(false);
  }), nullptr));

  mGameLayer->runAction(Sequence::create(DelayTime::create(0.5), CallFunc::create([this] {
    enableGame(false);
    enableGame(true);
  }), nullptr));
}
Exemplo n.º 2
0
void GameLevel::loadFx() {
  for (auto i : mEffects) {
    ParticleSystem *ps = ParticleSystemQuad::create(i);
    ParticleBatchNode *batch = ParticleBatchNode::createWithTexture(ps->getTexture());
    batch->addChild(ps);
    mGameLayer->getBlockRoot()->addChild(batch, ZORDER_PARTICLE);
    batch->setCameraMask((unsigned short) CameraFlag::USER2);
    mFxNodes.push_back(batch);
  }
}