Hey ive been doing some tutorials for Sprite Animation, & i have made an animation but my fps goes down really low & it just slows down the program in general.
I first thought it was BufferedImage but change it but still made no no difference. I’ll post the main part that is making it lag so much (its updating each image).
//Updating the animation image
public void update(long time) {
if (running) {
if (time - previousTime >= speed) {
currentFrame++;
if (currentFrame < frames.size()) {
sprite = frames.get(currentFrame); <<< main part of the lag
} else {
currentFrame = 0;
sprite = frames.get(currentFrame);
}
previousTime = time;
}
}
}
//updating the animation on screen
public void update(Display display) {
animation.update(System.currentTimeMillis());
}
Thanks for taking a look