destroy all images when closing
This commit is contained in:
parent
a02613bb76
commit
156026bd9b
|
@ -461,6 +461,37 @@ public enum GameImage {
|
|||
}
|
||||
}
|
||||
|
||||
public static void destroyAll() {
|
||||
for (GameImage img : GameImage.values()) {
|
||||
destroyAll(img.defaultImages);
|
||||
destroyImage(img.defaultImage);
|
||||
destroyAll(img.skinImages);
|
||||
destroyImage(img.skinImage);
|
||||
img.isSkinned = false;
|
||||
img.defaultImages = img.skinImages = null;
|
||||
img.defaultImage = img.skinImage = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyAll(Image[] imgs) {
|
||||
if (imgs == null) {
|
||||
return;
|
||||
}
|
||||
for (Image i : imgs) {
|
||||
destroyImage(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyImage(Image image) {
|
||||
if (image == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
image.destroy();
|
||||
} catch (SlickException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bitmask image type from a type string.
|
||||
* @param type the type string
|
||||
|
|
|
@ -212,6 +212,8 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
|||
}
|
||||
|
||||
public void teardown() {
|
||||
InternalTextureLoader.get().clear();
|
||||
GameImage.destroyAll();
|
||||
Display.destroy();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user