Testing custom loading screens with Pulpcore and Sloppy
Saturday, March 29th, 2008Pulpcore provides a pretty good user experience with its built in loading scene. How ever there may be time where you wish to do some thing a little more interesting.
Like most thing in Pulpcore this is pretty easy to do.
In my example I have chosen to have a skull themed loading screen.
Here is the very basic steps needed to create a custom loading scene.
The first thing you need to do is extend the loading scene Pulpcore provides.
public class LoadingScene extends pulpcore.scene.LoadingScene
Next create a constructor that tells the base loading screen what asset file to load and the scene to display after loading.
public LoadingScene() { super("skull.zip" , new SkullScene()); }
Next is to override the load function.
It is here that we tell the main layer to discard all of the default sprites.
I have read that you should create a timeline that animates out your scene and calls the new scene by setting the onCompletion with your custom timeline. I forgot to do this in my demo and it still worked ok. So if you find your loading scene loads but never moves on I would check out that bit.
public void load() { super.load(); getMainLayer().removeAll(); //super.onCompletion(timeline); //Own sprites go here }
Next override the update function to update your scene as needed.
You will need to call the super.update as well. This will get the existing asset download management code to do its thing so you can focus on drawing some thing interesting.
public void update(int elapsedTime) { //Update your loading screen here super.update(elapsedTime); }
So in a nutshell that is a basic custom loading scene.
After I had this all setup and running came the question of how do I test it?
Running locally my applet would load in under a second so you would only get the briefest glimpse of it.
That is when I found this cool Java app called Sloppy
Sloppy will emulate a slow connection for you. So for testing I build my applet and drop it onto my local web server.
Next I run Sloppy set the connection speed to some thing slow, point it my new Pulpcore applet and off it goes.
I have a demo of custom loading screens here
Here is a plain text link so you can try it with Sloppy if you happen to have a fast connection and would other wise miss the loading screen.
http://blog.alexjeffery.org/files/pulpcore/skulls/
You should see a black screen with some white skulls flying about and a big loading bar with a skull on it.
After that loads up the same deal but in white with pretty colors, a logo and some music that where loading during the loading scene.
Demo
Source code is here
Music credits to my friend Pimpfish