When a player clicks start, my app immediately switches to the first level. My question is how do I incorporate a smooth transition within Slick?
I'm not sure this kind of functionality is engine-specific. If you have a way of setting a global alpha, then you could do it just fine.
Interpolate the scene alpha and the menu alpha through time, for example, for one second...
We have two objects,
What we do here is increase the alpha of the game, and decrease the alpha of the menu, making it slowly fade away. If you set
I hope I cleared things up.
You can apply transition effects when changing a game state, just use the overloaded method:
On this javadoc page you can see, what transitions are available: JavaDoc: Transition
I have just tried it out in my current prototype and its pretty easy to do. Example of how I made a transition from my main menu state to the gameplay state (the main menu looks pretty ugly and isn't a menu at all, thats because I haven't implemented it yet ;) but I think it should suffice as example.
The code I used to produce this simple transition from the menu to white and then to the game state looks like this:
If you look at the method signature of enterState you see, that the overload will take the state id, a fade out and a fade in transition. I simply took two of the transitions and looked at the constructor of them. There you already see, what options are possible (color and duration in the case of the fade in/out).
Just try out the classes, look at the methods and constructors and try to find out how they work, if to few documentation is provided.
Edit: Make sure that your update and render methods work, even if init hasn't run yet. I think the transitions may cause the render method to be called before init.