dermetfan

simple asset management

Jul 12th, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package net.dermetfan.someLibgdxTests;
  2.  
  3. import com.badlogic.gdx.graphics.Texture;
  4.  
  5. public abstract class Assets {
  6.    
  7.     public static Texture player, ball, something;
  8.    
  9.     public static void load() {
  10.         player = new Texture("img/player.png");
  11.         ball = new Texture("img/ball.png");
  12.         something = new Texture("img/something.png");
  13.     }
  14.  
  15.     public static void dispose() {
  16.         player.dispose();
  17.         ball.dispose();
  18.         something.dispose();
  19.     }
  20.  
  21. }
  22.  
  23. // loading and disposing
  24. public class MyLibgdxGame extends Game {
  25.  
  26.     @Override
  27.     public void create() {
  28.         Assets.load();
  29.     }
  30.  
  31.     // ...
  32.  
  33.     @Override
  34.     public void dispose() {
  35.         super.dispose();
  36.         Assets.dispose();
  37.     }
  38.  
  39. }
  40.  
  41. // usage is simple:
  42. public class IUseAssets {
  43.  
  44.     public void inThisMethod() {
  45.         int width = Assets.player.getWidth();
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment