示例#1
0
 private void drawTippingOver(SpriteBatch batch) {
   Vector2 pos = character.getPosition();
   tipOverStateTime += Gdx.graphics.getDeltaTime();
   switch ((int) character.rotation) {
     case 0:
       batch.draw(tipOverE.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 45:
       batch.draw(tipOverNe.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 90:
       batch.draw(tipOverN.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 135:
       batch.draw(tipOverNw.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 180:
       batch.draw(tipOverW.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 225:
       batch.draw(tipOverSw.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 270:
       batch.draw(tipOverS.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
     case 315:
       batch.draw(tipOverSe.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
       break;
   }
 }
示例#2
0
  private void drawAttacking(SpriteBatch batch) {
    Vector2 pos = character.getPosition();
    float stateTime = character.attackAnimationHandler.stateTime;

    switch ((int) character.rotation) {
      case 0:
        batch.draw(attackE.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 45:
        batch.draw(attackNe.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 90:
        batch.draw(attackN.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 135:
        batch.draw(attackNw.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 180:
        batch.draw(attackW.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 225:
        batch.draw(attackSw.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 270:
        batch.draw(attackS.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
      case 315:
        batch.draw(attackSe.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4);
        break;
    }
  }
示例#3
0
  private void drawRunning(SpriteBatch batch) {
    stateTime += Gdx.graphics.getDeltaTime();
    Rectangle bounds = character.getBounds();
    // Just update when the character is moving to prevent sudden change of animation
    if (character.isMoving()) {
      moveX = character.moveIndicatorX;
      moveY = character.moveIndicatorY;
    }

    // character is moving east
    if (moveX > 0) {

      // Moving north east
      if (moveY > 0) {
        batch.draw(runNe.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4);
      } else if (moveY < 0) {
        batch.draw(runSe.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4);
      } else {
        batch.draw(runE.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4);
      }
      // Moving west
    } else if (moveX < 0) {
      // Moving north
      if (moveY > 0) {
        batch.draw(runNw.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4);
      } else if (moveY < 0) {
        batch.draw(runSw.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4);
      } else {
        batch.draw(runW.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4);
      }
    } else {
      // Moving north
      if (moveY > 0) {
        batch.draw(runN.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4);
      } else if (moveY < 0) {
        batch.draw(runS.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4);
      }
    }
  }