annimation du ptit bonhomme

This commit is contained in:
Damien 2021-05-14 11:53:51 +02:00
parent 08d0802731
commit b959cc3fa7
3 changed files with 7 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -19,6 +19,7 @@ public class Player extends EntityQuad {
private Planet home; private Planet home;
private boolean active; private boolean active;
private ArrayList<Texture> texture; private ArrayList<Texture> texture;
private int T = 0;
// ---------- CONSTRUCTORs ---------- // ---------- CONSTRUCTORs ----------
@ -73,8 +74,12 @@ public class Player extends EntityQuad {
@Override @Override
public void draw(Batch batch, float parentAlpha) { public void draw(Batch batch, float parentAlpha) {
batch.draw(texture.get(0), getPosition().x - getWidth()/2, getPosition().y - getHeight()/2, getWidth()/2, getHeight()/2, getWidth(), getHeight(), T++;
1, 1, getRotation(), 0, 0, texture.get(0).getWidth(), texture.get(0).getHeight(), false, false); T %= 100;
int i = (int) (T * ((float) texture.size() / 100));
System.out.println(i);
batch.draw(texture.get(i), getPosition().x - getWidth()/2, getPosition().y - getHeight()/2, getWidth()/2, getHeight()/2, getWidth(), getHeight(),
1, 1, getRotation(), 0, 0, texture.get(i).getWidth(), texture.get(i).getHeight(), false, false);
super.draw(batch, parentAlpha); super.draw(batch, parentAlpha);
} }