I thought it might be a good idea, to share with you some of the things I have learned during the development of “Balloon Mayhem”. I will not go into very much detail about the standard things in Silverlight like explaning VisualStateManager and stuff like that.

Switching between gamescreens
In Balloon Mayhem I of course have different screens/states, actually I have the following:

  • SplashScreen
  • Menu
  • Playing
  • GameOver
  • Credits

Like almost all other games, I need to display them at different points in the game based on different events. This is all good, but how do you do that the best way in Silverlight? You have two options:

  1. Do it all in code
  2. Using the VisualStateManager

As I’m a person who want to try out new things and tools, I thought that the VisualStateManager were the best and “right” way to do this. Later I discovered that is wasn’t :)

It all started out good as I had 3 states, but as the game got a little more complex I needed more “screens/states”. At release the states looked like this.

image

All these “game states” are hold and controled by the Page class. Every state have an “container” (Grid/Canvas) it displays/hides. It’s almost like a 1-to-1 relationship between a state and a container. For instance the “SplashScreen” state, sets the visibility to Visible etc.

image

The first problem I faced were how the “Base” state should be. “What are you talking about?” are you now thinking. Well, you have two options. Either you make ALL the containers Collapsed in the Base state and then displays the one you need in the particular state. Else you can have them all be Visible in the Base state and then, when you need to go to a particular states, set all the other containers to Collapsed. I chose the first solution as it seemed easiest at first, as I only need to displays the actual container that I want to show.

Sadly, that gave me some other problems, or really not problems, but “complications” when developing the game. When I for instance need to change something on the “PlayingGrid” container, I need to either set the Visibility of that to Visible in the Base state, to be able to work with it. The downside here is, that I pretty often forget to set it back to Collapsed, which makes the game unplayable. The other thing I can do it to click the actual “Playing” state. This is all good, as I then see my game as it will look when played, but beware! If I forget to turn off the “Record” feature, all my changes will be recorded as changes between states and hell breaks loose. To make it really funny, I need to remove this “Record” thing EVERYTIME I switch state inside Blend.

image

image

I had a lot of “fun” with this and my conclusion is, that this is NOT the way to handle switching between game screens/states. To find the “right” way, or just a better one I asked on the Silverlight.net forum, what people did. http://silverlight.net/forums/t/100350.aspx It seems that people are doing this kind of switching between screens in code, so that’s what I will do in my next project too :) If you look at the thread I link to, you see that CameronAlbert is giving a simple example of how to do this.

Silverlight.live.com – hosting silverlight apps and video
The intro movie in Balloon Mayhem is hosting on silverlight.live.com, which is working really good. I just discovered this service some months ago, so when I needed to add an intro/splash movie to this game, this were the way to go. It works pretty go, easy to use and best of all – free. Not much to tell here, just wanted to point you to it if you didn’t knew it:http://silverlight.live.com/

If you have questions or feedback, please leave a comment.

– Enjoy!