1010import com .badlogic .gdx .graphics .g2d .TextureRegion ;
1111import com .badlogic .gdx .math .Vector2 ;
1212import com .badlogic .gdx .utils .Array ;
13+ import com .badlogic .gdx .utils .Disposable ;
1314import com .badlogic .gdx .utils .GdxRuntimeException ;
1415import com .esotericsoftware .spine .Bone ;
1516import com .talosvfx .talos .runtime .scene .components .*;
1920
2021import java .util .Comparator ;
2122
22- public class GameObjectRenderer {
23+ public class GameObjectRenderer implements Disposable {
2324 private ComponentRenderer <SpriteRendererComponent > spriteRenderer ;
2425 private ComponentRenderer <MapComponent > mapRenderer ;
2526 private ComponentRenderer <ParticleComponent <?>> particleRenderer ;
@@ -39,9 +40,13 @@ public class GameObjectRenderer {
3940
4041
4142 private static TextureRegion brokenRegion ;
43+ private static Texture brokenTexture ;
4244
4345 public GameObjectRenderer () {
44- brokenRegion = new TextureRegion (new Texture (Gdx .files .classpath ("missing.png" )));
46+ if (brokenRegion == null ) {
47+ brokenTexture = new Texture (Gdx .files .classpath ("missing.png" ));
48+ brokenRegion = new TextureRegion (brokenTexture );
49+ }
4550
4651 spriteRenderer = createSpriteRenderer ();
4752 mapRenderer = createMapRenderer ();
@@ -447,4 +452,13 @@ public void setCamera (Camera camera) {
447452 public void setSkipUpdates (boolean skipUpdates ) {
448453 this .skipUpdates = skipUpdates ;
449454 }
455+
456+ @ Override
457+ public void dispose () {
458+ if (brokenRegion != null ) {
459+ brokenTexture .dispose ();
460+ brokenRegion = null ;
461+ brokenTexture = null ;
462+ }
463+ }
450464}
0 commit comments