Game Development Reference
In-Depth Information
LoadingScreen: Fetching the Assets from Disk
With those classes at hand, we can now easily implement the loading screen. Listing 6-4
shows the code.
Listing 6-4. LoadingScreen.java; Loads All Assets and the Settings
package com.badlogic.androidgames.mrnom;
import com.badlogic.androidgames.framework.Game;
import com.badlogic.androidgames.framework.Graphics;
import com.badlogic.androidgames.framework.Screen;
import com.badlogic.androidgames.framework.Graphics.PixmapFormat;
public class LoadingScreen extends Screen {
public LoadingScreen(Game game) {
super (game);
}
We let the LoadingScreen class derive from the Screen class we defined in Chapter 3.
This requires that we implement a constructor that takes a Game instance, which we hand
to the superclass constructor. Note that this constructor will be called in the MrNomGame.
getStartScreen() method we defined earlier.
public void update( float deltaTime) {
Graphics g = game.getGraphics();
Assets. background = g.newPixmap("background.png", PixmapFormat. RGB565 );
Assets. logo = g.newPixmap("logo.png", PixmapFormat. ARGB4444 );
Assets. mainMenu = g.newPixmap("mainmenu.png", PixmapFormat. ARGB4444 );
Assets. buttons = g.newPixmap("buttons.png", PixmapFormat. ARGB4444 );
Assets. help1 = g.newPixmap("help1.png", PixmapFormat. ARGB4444 );
Assets. help2 = g.newPixmap("help2.png", PixmapFormat. ARGB4444 );
Assets. help3 = g.newPixmap("help3.png", PixmapFormat. ARGB4444 );
Assets. numbers = g.newPixmap("numbers.png", PixmapFormat. ARGB4444 );
Assets. ready = g.newPixmap("ready.png", PixmapFormat. ARGB4444 );
Assets. pause = g.newPixmap("pausemenu.png", PixmapFormat. ARGB4444 );
Assets. gameOver = g.newPixmap("gameover.png", PixmapFormat. ARGB4444 );
Assets. headUp = g.newPixmap("headup.png", PixmapFormat. ARGB4444 );
Assets. headLeft = g.newPixmap("headleft.png", PixmapFormat. ARGB4444 );
Assets. headDown = g.newPixmap("headdown.png", PixmapFormat. ARGB4444 );
Assets. headRight = g.newPixmap("headright.png", PixmapFormat. ARGB4444 );
Assets. tail = g.newPixmap("tail.png", PixmapFormat. ARGB4444 );
Assets. stain1 = g.newPixmap("stain1.png", PixmapFormat. ARGB4444 );
Assets. stain2 = g.newPixmap("stain2.png", PixmapFormat. ARGB4444 );
Assets. stain3 = g.newPixmap("stain3.png", PixmapFormat. ARGB4444 );
Assets. click = game.getAudio().newSound("click.ogg");
Assets. eat = game.getAudio().newSound("eat.ogg");
Assets. bitten = game.getAudio().newSound("bitten.ogg");
Settings. load (game.getFileIO());
game.setScreen( new MainMenuScreen(game));
}
 
Search WWH ::




Custom Search