Example #1
0
  @Override
  public void act(float delta) {
    super.act(delta);

    switch (state) {
      case TRY_CLOSE:
        if (!isTouchBall()) close();
        else Gdx.app.log("gatte", "balll");
        break;
      case CLOSING:
        if (animationFrame > 0) {
          animationFrame--;
          sprite.setRegion(textureAtlasRegions.get(animationFrame));
        } else {
          state = State.CLOSED;
        }
        break;
      case OPENING:
        if (animationFrame < textureAtlasRegions.size - 1) {
          animationFrame++;
          sprite.setRegion(textureAtlasRegions.get(animationFrame));
        } else {
          state = State.OPENED;
        }
        break;
    }
  }
Example #2
0
 @Override
 public void draw(Batch batch, float parentAlpha) {
   super.draw(batch, parentAlpha);
   stateTime += Gdx.graphics.getDeltaTime();
   batch.draw(
       animation.getKeyFrame(stateTime, true),
       (screenRectangle.x - (screenRectangle.width * 0.1f)),
       screenRectangle.y,
       screenRectangle.width * 1.2f,
       screenRectangle.height * 1.1f);
 }
Example #3
0
  @Override
  public void applyWorld(World world, BodyDef.BodyType bodyType) {
    super.applyWorld(world, bodyType);

    switch (state) {
      case OPENING:
        open();
        break;
      case CLOSING:
        close();
        break;
    }
  }
Example #4
0
 @Override
 public void act(float delta) {
   super.act(delta);
   body.setLinearVelocity(getUserData().getLinearVelicity());
 }