I cleaned the class a little, to go back to the original.
Heres the result :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| package Atlas;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Animation; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion;
public class Explosions {
private static final int FRAME_COLS = 8; private static final int FRAME_ROWS = 6; Animation walkAnimation; Texture walkSheet; TextureRegion[] walkFrames; SpriteBatch spriteBatch; TextureRegion currentFrame; float stateTime;
private int textureWidth,textureHeight; public Explosions() { walkSheet = new Texture(Gdx.files.internal("Explosion2spritesheet.png"));
TextureRegion[][] tmp = TextureRegion.split(walkSheet, walkSheet.getWidth() / FRAME_COLS, walkSheet.getHeight() / FRAME_ROWS);
walkFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS]; int index = 0; for (int i = 0; i < FRAME_ROWS; i++) { for (int j = 0; j < FRAME_COLS; j++) { walkFrames[index++] = tmp[i][j]; } }
walkAnimation = new Animation(0.025f, walkFrames); spriteBatch = new SpriteBatch(); stateTime = 0f; textureWidth = (walkSheet.getWidth() / FRAME_COLS); textureHeight = (walkSheet.getHeight() / FRAME_ROWS); } public TextureRegion getCurrentFrame() { stateTime += Gdx.graphics.getDeltaTime(); currentFrame = walkAnimation.getKeyFrame(stateTime,false); return currentFrame; }
public int getTextureWidth() { return textureWidth; }
public int getTextureHeight() { return textureHeight; } } |
So , i have some ideas...
One would make this class as a model, and create an explosion class and create an arrayList at gameupdate with the state and explosions positions, and keep drawing....
Well, i guess thats the only idea.
Btw, should i make an Atlas for just this img ?