Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Codigo para generar la animacion
- imagen = new Texture("run.png");
- TextureRegion[][] temp = TextureRegion.split(imagen, imagen.getWidth() / 8, imagen.getHeight() - 34);
- regionsMovimiento = new TextureRegion[8];
- for (int i = 0; i < regionsMovimiento.length; i++) {
- regionsMovimiento[i] = temp[0][i];
- }
- animation = new Animation(1, regionsMovimiento);
- tiempo = 0f;
- //Crear la animacion en el draw
- @Override
- public void draw(Batch batch, float parentAlpha) {
- setPosition(body.getPosition().x, body.getPosition().y);
- tiempo += Gdx.graphics.getDeltaTime() * 12;
- frameActual = (TextureRegion) animation.getKeyFrame(tiempo, true);
- batch.draw(frameActual, getX(), getY());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement