Heya.
I kept thinking and thinking and thinking but i still dont know the better way to create a class/method/functions to manage several explosions happening.
I mean the drawing and some kind of ArrayList to control them, also, idk how to create a flag using this class here, to know when the drawing finished....
soo, if anyone could at least tell me what i need to research , i dont want to abuse anyone to give me the answer, but if you can atleast point me to the right direction, i would appreciate a looooot.
Heres the class that im using, i got here from a friend, i think from 65k user?
Anyway, here it is :
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| 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; import java.util.ArrayList;
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 ArrayList<Explosions> explosionsHappening; private int posx,posy; private int TEXTURE_WIDTH,TEXTURE_HEIGHT; public Explosions() { explosionsHappening = new ArrayList<>(); 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; TEXTURE_WIDTH = (walkSheet.getWidth() / FRAME_COLS); TEXTURE_HEIGHT = (walkSheet.getHeight() / FRAME_ROWS); } public TextureRegion getCurrentFrame() { stateTime += Gdx.graphics.getDeltaTime(); currentFrame = walkAnimation.getKeyFrame(stateTime,false); return currentFrame; }
public ArrayList<Explosions> getExplosionsHappening() { return explosionsHappening; }
public void addExplosionsHappening(Explosions exp,int posX,int posY) { exp.posx = posX; exp.posy = posY; explosionsHappening.add(exp); System.out.println("Explosion [x] :" + exp.posx); System.out.println("Explosion [y] :" + exp.posy); }
public int getPosx() { return posx; }
public int getPosy() { return posy; }
public int getTEXTURE_WIDTH() { return TEXTURE_WIDTH; }
public int getTEXTURE_HEIGHT() { return TEXTURE_HEIGHT; } } |