0
\$\begingroup\$

How i can stop animation at last frame.

@Override
public void create(){

textureAtlas = new TextureAtlas("pack.atlas"); 
stage = new Stage(new ScreenViewport());
sb = new SpriteBatch();

 final TextButton button = new TextButton("Start",skin , "default");
        button.setWidth(220);
        button.setHeight(50);


  button.addListener(new ClickListener(){
            @Override
            public void clicked(InputEvent event, float x, float y) {
                spinAnimation.setFrameDuration(0.5f);
                int i = 0;
     Timer.schedule(new Timer.Task() {
                @Override
                public void run() {
                    spinAnimation.setFrameDuration(0f);


                }

            },1);


            }
        });

    stage.addActor(button);



           Gdx.input.setInputProcessor(stage);
    }

@Override
   public void render() {

   elepsedTime += Gdx.graphics.getDeltaTime();
   Gdx.gl.glClearColor(0,0,0,1);       
   Gdx.gl.glClear(com.badlogic.gdx.graphics.GL20.GL_COLOR_BUFFER_BIT);

   sb.begin();
   stage.act(Gdx.graphics.getDeltaTime());
   sb.draw(spinAnimation.getKeyFrame(elepsedTime,true), 50,  60


   sb.end();
   stage.draw();
    }
\$\endgroup\$
1
\$\begingroup\$

do spinAnimation.getKeyFrame(Math.min(elapsedTime,spinAnimation.getAnimationDuration()),true)

or you know just dont have the animation looping. spinAnimation.getKeyFrame(elapsedTime,false)

and make sure PlayMode is set to PlayMode.NORMAL. If you didnt change it before then it should already be set to normal.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.