Esempio n. 1
0
  public Samurai() {
    setName("samurai");

    idleAnimation = new SpriteAnimation(1f, "samurai_", 1, 2);
    blockAnimation = new SpriteAnimation(.5f, "samurai_block_", 1, 2);

    idleAnimation.setPlayMode(SpriteAnimation.LOOP);
    blockAnimation.setPlayMode(SpriteAnimation.LOOP);

    currentAnimation = idleAnimation;
  }
Esempio n. 2
0
  public void draw(SpriteBatch batch, float parentAlpha) {
    stateTime += Gdx.graphics.getDeltaTime();

    Sprite toRender = currentAnimation.getKeyFrame(stateTime);

    // -1 to account for the sword below his feet
    toRender.setPosition(getX(), getY() - 1);
    toRender.setOrigin(
        toRender.getX() + toRender.getWidth(), toRender.getY() + toRender.getHeight());
    toRender.setRotation(getRotation());

    setSize(toRender.getWidth(), toRender.getHeight());
    setOrigin(toRender.getOriginX(), toRender.getOriginY());

    toRender.draw(batch);

    if (TheLoveOfRice.DRAW_DEBUG) {
      drawDebug(batch);
    }
  }