Load idle animation when nothing key pressed

Anything about development not directly related to libgdx, e.g. OpenGL, Android APIs etc.

Load idle animation when nothing key pressed

Postby quangtran » Sun Jan 28, 2018 6:33 am

I can move a player forward/backward with animation walking with left/right key but I want when nothing key pressed an idle animation must load to player instead of animation walking. I capture event the keyup but not ok, it began to messy.

Thank you for reading.

Code: Select all
public void create () {

      float w = Gdx.graphics.getWidth();
      float h = Gdx.graphics.getHeight();
      batch = new SpriteBatch();   
      playerAtlas = new TextureAtlas(Gdx.files.internal("idle.atlas"));
      playerAnimation =new Animation(1/1.0f,playerAtlas.getRegions());   
                currentAnimation = playerAnimation;      

public void render () {

      Gdx.gl.glClearColor(1, 1, 1, 1);
      elapsedTime += Gdx.graphics.getDeltaTime();
Last edited by quangtran on Sun Jan 28, 2018 6:09 pm, edited 6 times in total.
Posts: 2
Joined: Sun Jan 28, 2018 6:01 am

Re: how to start and stop animation

Postby evilentity » Sun Jan 28, 2018 9:44 am

Frame you get depends on time you pass in, if you dont change it, you will get the same frame.
Looking for a freelancer? PM me!
Posts: 4688
Joined: Wed Aug 24, 2011 11:37 am

Return to General Development

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest