Sorry if this question has already been asked, I'm new to Slick and these forums. I've been following one of the tutorials and trying to integrate the Slick features with a game I created a few months back.
Anyway, I am loading images and sounds in the init() method of my MainMenu state. I was wondering if there was an easy way to display a simple loading message or splash screen while the sounds and images load. Right now, there's about 5 seconds of black screen before my main menu pops up. I was doing some research and have found DeferredResource and LoadingList classes, but I can't figure out how to implement them. Any pointers *hehe programming pun* in the right direction would be much appreciated.
Here is the code for my MainMenu state class so far:
Code:
package com.lc.apples;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class MainMenu extends BasicGameState
{
public int stateID;
public Image backGround;
public Image title;
public Image startOption;
public Image exitOption;
float startScale = 1F;
float exitScale = 1F;
float titleScale = 1.1F;
final float SCALESTEP = 0.001F;
public MainMenu(int state)
{
stateID = state;
}
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException
{
backGround = new Image("res/gui/background.png");
title = new Image("res/gui/title.png");
Image menuOptions = new Image("res/gui/menuoptions.png");
startOption = menuOptions.getSubImage(0, 0, 399, 128);
exitOption = menuOptions.getSubImage(0, 155, 399, 299);
Sound music = new Sound("res/sound/song.ogg");
//i want to loop music once the loading is complete
music.loop();
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException
{
backGround.draw(0, 0);
title.draw(50, 10, titleScale);
startOption.draw(300, 250, startScale);
exitOption.draw(300, 430, exitScale);
}
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException
{
Input input = gc.getInput();
int mouseX = input.getMouseX();
int mouseY = input.getMouseY();
boolean insideStart = false;
boolean insideExit = false;
if((mouseX > 300 && mouseX < 690)
&& (mouseY > 250 && mouseY < 350))
{
insideStart = true;
}
else if((mouseX > 300 && mouseX < 660)
&& (mouseY > 430 && mouseY < 590))
{
insideExit = true;
}
if(insideStart)
{
exitScale = 1F;
if(startScale < 1.2F)
{
startScale += SCALESTEP;
}
if(input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON))
{
sbg.enterState(FallingApples.PLAYSCREEN);
}
}
else if(insideExit)
{
startScale = 1F;
if(exitScale < 1.2F)
{
exitScale += SCALESTEP;
}
if(input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON))
{
gc.exit();
}
}
else
{
startScale = 1F;
exitScale = 1F;
}
}
public int getID()
{
return stateID;
}
}