简体   繁体   中英

Java LibGDX moving animation

How can I move Sprite fluently?I have tried in this way.

@Override
    public void render(float delta) {
        Gdx.graphics.getGL20().glClearColor( 1F, 1F, 1F, 1F );
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        batch.setProjectionMatrix(camera.combined);

            batch.begin();
               mySprite.draw(batch);
               mySprite.setX(BladeAnimation.bladeFalling());
            batch.end();
}

I have changed xPosition with other function but the animation is not playing fluently.

You have to run the code that is changing the position in the render() method, other wise it changes only once. Unless if you are changing the position elsewhere. Show the code that changes the position to get a better answer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM