mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-01 07:39:35 +01:00
Legger til korrekt fjerning av innlastede ressurser brukt i TextureConverterUtil
This commit is contained in:
parent
983c27f745
commit
9d914ad748
@ -10,12 +10,14 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||||
import inf112.fiasko.roborally.game.Game;
|
import inf112.fiasko.roborally.game.Game;
|
||||||
import inf112.fiasko.roborally.game.IDrawableGame;
|
import inf112.fiasko.roborally.game.IDrawableGame;
|
||||||
import inf112.fiasko.roborally.objects.IDrawableObject;
|
import inf112.fiasko.roborally.objects.IDrawableObject;
|
||||||
import inf112.fiasko.roborally.utility.IOUtil;
|
import inf112.fiasko.roborally.utility.IOUtil;
|
||||||
|
import inf112.fiasko.roborally.utility.TextureConverterUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -102,6 +104,9 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
|
|||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
batch.dispose();
|
batch.dispose();
|
||||||
|
for (Disposable disposable : TextureConverterUtil.getDisposableElements()) {
|
||||||
|
disposable.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,6 +3,7 @@ package inf112.fiasko.roborally.utility;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
import inf112.fiasko.roborally.element_properties.Direction;
|
import inf112.fiasko.roborally.element_properties.Direction;
|
||||||
import inf112.fiasko.roborally.element_properties.RobotID;
|
import inf112.fiasko.roborally.element_properties.RobotID;
|
||||||
import inf112.fiasko.roborally.element_properties.TileType;
|
import inf112.fiasko.roborally.element_properties.TileType;
|
||||||
@ -15,7 +16,9 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +35,19 @@ public final class TextureConverterUtil {
|
|||||||
|
|
||||||
private TextureConverterUtil() {}
|
private TextureConverterUtil() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of all disposable elements which should be disposed when the software closes
|
||||||
|
* @return A list of disposable elements
|
||||||
|
*/
|
||||||
|
public static List<Disposable> getDisposableElements() {
|
||||||
|
List<Disposable> disposables = new ArrayList<>();
|
||||||
|
disposables.add(textureSheet);
|
||||||
|
disposables.add(robot1Texture);
|
||||||
|
disposables.add(robot2Texture);
|
||||||
|
disposables.add(robot3Texture);
|
||||||
|
return disposables;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the texture representing the tile
|
* Gets the texture representing the tile
|
||||||
* @param tile The tile to draw
|
* @param tile The tile to draw
|
||||||
|
Loading…
x
Reference in New Issue
Block a user