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 :
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;
//Width ¨¨ Height
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;
}
}