SHARE
TWEET

Untitled

a guest Sep 10th, 2014 199 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. //////////This is the Asset Manger class which is called first off when you launch your project.
  4.  
  5. public class Assets implements Screen{
  6.         private float WIDTH= 800;
  7.         private float HEIGHT = 480;
  8.        
  9.         public static EggWrap game;
  10.         public static AssetManager manager;
  11.         public static SpriteBatch batch;
  12.         public static OrthographicCamera cam;
  13.         BitmapFont font;
  14.         public static Texture bg;
  15.         public static TextureRegion bgR;
  16.         String loading;
  17.         float progress;
  18.         float prog;
  19.  
  20.         public Assets(EggWrap game){
  21.                 font = new BitmapFont(Gdx.files.internal("font.fnt"), Gdx.files.internal("font.png"),false);
  22.                 font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
  23.                
  24.         Assets.game = game;
  25.        
  26.         manager = new AssetManager();
  27.        
  28.         cam = new OrthographicCamera(WIDTH,HEIGHT);
  29.         cam.position.set(WIDTH / 2, HEIGHT / 2, 0);
  30.  
  31.         batch = new SpriteBatch();
  32.          
  33.         bg = new Texture(Gdx.files.internal("splash.png"));
  34.         bg.setFilter(TextureFilter.Linear, TextureFilter.Linear);
  35.         bgR = new TextureRegion(bg,0,0,800,480);
  36.        
  37.         load();
  38.  
  39.        
  40.        
  41.         }
  42.  
  43.  
  44. public static void load(){
  45.        
  46.         manager.load("01.jpg", Texture.class);
  47.         manager.load("02.jpg", Texture.class);
  48.         manager.load("03.jpg", Texture.class);
  49.         manager.load("04.jpg", Texture.class);
  50.         manager.load("05.jpg", Texture.class);
  51.         manager.load("06.jpg", Texture.class);
  52.         manager.load("07.jpg", Texture.class);
  53.         manager.load("08.jpg", Texture.class);
  54.         manager.load("09.jpg", Texture.class);
  55.         manager.load("10.jpg", Texture.class);
  56.         manager.load("11.jpg", Texture.class);
  57.         manager.load("12.jpg", Texture.class);
  58.        
  59.         manager.load("menu.jpg", Texture.class);
  60.         manager.load("ingredients.jpg", Texture.class);
  61.         manager.load("utils.jpg", Texture.class);
  62.         manager.load("menuNav.png", Texture.class);
  63.         manager.load("nav.png", Texture.class);
  64.        
  65.        
  66. }
  67.  
  68. public static void unload(){
  69.        
  70. }
  71.  
  72.  
  73. public void render(float delta) {
  74.                 Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
  75.                 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  76.                 cam.update();
  77.                 batch.setProjectionMatrix(cam.combined);
  78.                 batch.begin();
  79.                 batch.draw(bgR, 0, 0);
  80.                 progress =  manager.getProgress();
  81.        
  82.                 loading = new String( "loading" + progress);
  83.                 boolean result =  manager.update();
  84.                
  85.                 if(result){
  86.                         game.setScreen(new Menu(game));
  87.                        
  88.                 System.out.println("assets loaded - setting new screen");
  89.                 }
  90.                
  91.                
  92.                
  93.                
  94.                 font.draw(batch, "Loading " +(int) (progress *100)  , 800 / 2 - 40, 30);
  95.         //      System.out.println("" +(int) (progress *100) );
  96.                 batch.end();
  97. }
  98.  
  99.  
  100.  
  101.  
  102. @Override
  103. public void resize(int width, int height) {
  104.        
  105. }
  106.  
  107. @Override
  108. public void show() {
  109.        
  110.  
  111. }
  112.  
  113. @Override
  114. public void hide() {
  115.        
  116.  
  117. }
  118.  
  119. @Override
  120. public void pause() {
  121.        
  122.  
  123. }
  124.  
  125. @Override
  126. public void resume() {
  127.        
  128.  
  129. }
  130.  
  131. @Override
  132. public void dispose() {
  133.        
  134.        
  135.  
  136. }
  137.  
  138.  
  139. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top