Added Textures class to store some common solid color textures

This commit is contained in:
Collin Smith 2019-01-21 00:12:51 -08:00
parent ab779a4fce
commit 605bd6f7f2
3 changed files with 33 additions and 0 deletions

View File

@ -99,6 +99,7 @@ public class Client extends Game {
private Colors colors;
private Cursor cursor;
private Audio audio;
private Textures textures;
private boolean forceWindowed;
private boolean forceDrawFps;
@ -219,6 +220,7 @@ public class Client extends Game {
Diablo.colors = colors = new Colors();
Diablo.cursor = cursor = new Cursor();
Diablo.audio = audio = new Audio(assets);
Diablo.textures = textures = new Textures();
Collection<Throwable> throwables;
Diablo.commands = commands = new GdxCommandManager();
@ -426,6 +428,7 @@ public class Client extends Game {
Diablo.colors = colors;
Diablo.cursor = cursor;
Diablo.audio = audio;
Diablo.textures = textures;
super.resume();
}
@ -458,6 +461,7 @@ public class Client extends Game {
Gdx.app.debug(TAG, "Disposing assets...");
palettes.dispose();
colormaps.dispose();
textures.dispose();
assets.dispose();
try {

View File

@ -48,4 +48,5 @@ public class Diablo {
public static DT1s dt1s;
public static Cursor cursor;
public static Audio audio;
public static Textures textures;
}

View File

@ -0,0 +1,28 @@
package gdx.diablo;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.Disposable;
public class Textures implements Disposable {
public final Texture white;
public Textures() {
white = createTexture(Diablo.colors.white);
}
public Texture createTexture(Color color) {
Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pixmap.setColor(color);
pixmap.fill();
Texture texture = new Texture(pixmap);
pixmap.dispose();
return texture;
}
@Override
public void dispose() {
white.dispose();
}
}