Silverlight Tip of the Day #3: Silverlight Game Support, Limitations and Workarounds

[Blog Mirrored from https://silverlight.net/blogs/msnow/default.aspx]

While exploring techniques for game programming with Silverlight I came across some hurdles and discovered some workarounds. I plan to use this blog to track these issues for the purposing of hopefully saving you time from having to do similar research. In addition, I have added a Game Resources section where I will be putting links to other game tutorials for Silverlight.

If you discover any more, please send them my way and I will post them! Thank you.

Game Resources

What Silverlight Supports

  • JPG and PNG file formats.
  • Transparency through PNG files.
  • Keyboard and mouse input
  • Sound
  • Game UI layout through Grid elements.
  • Timers (animating, game loop, etc.)
  • Texture blending through Opacity.
  • Socket/TCP programming for multi-player networking support
  • Events (clicking, etc.)
  • Animation - WPF model that uses timers instead of frames.
  • Great debugging support through Visual Studio.

What Silverlight Currently Does Not Support

  • GIF or BMP file formats.

Work around : Use PNG (or JPG) files.

  • Creating images from subsets of larger images.

Work around: You have two options:

  1. Set a clipping region for the image such that you only show the part of the image you want displayed.
  2. Put each image in its own file. Unfortunately, for such work as animated sprites, this means a lot of individual files. Hard to manage.
  • Saving files locally - Due to security concerns, Silverlight 2.0 does not support saving. There is talk to support the SaveFileDialog in the future and I will track this progress closely letting you know what I learn. I need this feature myself (for my map editor)!

Work around: Save to a web server. See Michael Sync's blog here: https://michaelsync.net/category/silverlight under "Uploading with Silveright 2 Beta 1 and WCF"

  • Floating point values for positioning - if you tile images together to form a map, them scroll the map's X and Y position by a decimal value, you will see lines forming between the tiles.

Work around: Use rounded values.

  • Per pixel bitmap editing, bitmap filters (color matrix, etc) and effects (blur, glow, etc).

Work around: Through opacity you can do some pretty cool effects such as texture blending to smoothly blend transitions between map tiles. See this tutorial for an example.

  • 3D rendering – Silverlight 2 does not have any 3D support. However, seen Tip of the Day #71 on Silverlight 3. You will be happy to see that 3D is in the plans.

Work around: There are engines and demos out there that simulate 3D that work fairly well. Examples”

  1. https://www.markdawson.org/kit3d/
  2. https://www.codeplex.com/Balder
  • Sharing of resources is not allowed. For example, sharing a SolidColorBrush between rectangles. If you have 1000 rectangles, they will all need a separate brush for each rectangle.
  • Alignment for text in Textboxes.

Work around: You will have to programmatically center it.

Thank you,
--Mike Snow

 Subscribe in a reader

Comments