예제 #1
0
  /**
   * Apply damage and return true of death.
   *
   * @param damage
   * @return
   */
  public boolean applyDamage(double damage) {
    health -= damage;

    if (health > 0) {
      APAMultiplayerLayeredCharacterScene scene = getCharacterScene();

      // Build up "one shot" particle.
      SKEmitterNode emitter = getDamageEmitter();
      if (emitter != null) {
        emitter = (SKEmitterNode) emitter.copy();
        scene.addNode(emitter, APAWorldLayer.AboveCharacter);

        emitter.setPosition(getPosition());
        APAUtils.runOneShotEmitter(emitter, 0.15);
      }

      // Show the damage.
      SKAction damageAction = getDamageAction();
      if (damageAction != null) {
        runAction(damageAction);
      }
      return false;
    }

    performDeath();

    return true;
  }
예제 #2
0
 public void addToScene(APAMultiplayerLayeredCharacterScene scene) {
   scene.addNode(this, APAWorldLayer.Character);
   scene.addNode(shadowBlob, APAWorldLayer.BelowCharacter);
 }