コード例 #1
0
 public Allied(GeneralScreen screen, TextureRegion tRegion) {
   super(tRegion);
   this.screen = screen;
   // colocamos la pantalla en el centro inferior de la pantalla
   // setPosition((GameLogic.getScreenWidth() - getWidth()) / 2, posY);
   vel = 500;
   setPosition((GameLogic.getScreenWidth() - getWidth()) / 2, -getHeight());
   enter();
   setActive(true);
   setCanShoot(true);
 }
コード例 #2
0
  @Override
  public void act(float delta) {
    super.act(delta);

    dir = -Gdx.input.getAccelerometerX() / 4;

    if (dir == 0) {
      if (Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.isKeyPressed(Input.Keys.D)) {
        dir = 1;
      } else if (Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.isKeyPressed(Input.Keys.A)) {
        dir = -1;
      }
    }

    if (alive) {
      if (isActive()) {
        moveBy(dir * vel * delta, 0);
      }
      x = getX();
      y = getY();
      polygon.setPosition(x - 310, posY + getHeight() - 20);
      if (isActive()) {
        // comprobamos que la nave no de salga de la pantalla
        if (getX() < 5) {
          setX(10.1f);
        } else if (getX() > (GameLogic.getScreenWidth() - (getWidth() + 5))) {
          setX(GameLogic.getScreenWidth() - (getWidth() + 10));
        }
        if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) {
          if (screen._groupAllied.hasChildren()) {
            if (isCanShoot()) {
              shoot();
            }
          }
        }
      }
    }
  }
コード例 #3
0
 @Override
 public void kicked(int damage) {
   super.kicked(damage);
   try {
     if (GameLogic.getLivesGame() == 0) {
       Gdx.input.vibrate(1000);
     } else {
       Gdx.input.vibrate(200);
     }
   } catch (Exception e) {
     Gdx.app.log("VIBRATE", " --ERROR-- Can't vibrate");
   }
   for (int z = 0; z < damage; z++) {
     lostLiveGame();
   }
   if (getHealth() <= 0) {
     this.death();
   }
 }