XN4SL is a library dedicated to port existing XNA 2D games to the Sliverlight platform. XN4SL emulates XNA Framework classes for use with Silverlight applications. On current project stage XN4SL supports 2D games based on the Platformer XNA Starter Kit from Microsoft XNA Game Studio 3.0. Most of the game functionality was achieved and only minor changes in the code are required.

Any feedback or help will be great. If you create a game powered by XN4SL that you would like to share, you can submit it to SilverlightClub

To play game powered by XN4SL click the link here.

platformer.jpg

How to create your own Silverlight Platformer game powered by XN4SL?

Required tools: Microsoft Visual Studio 2008 SP1 with Silverlight Tools and XNA Game Studio 3.0.
  • In VS2008 create new project: "XNA Game Studio 3.0"->"Platformer Starter Kit 3.0" and name it "SilverligthPlatformer"
  • Create new "Silverlight"->"Silverlight Application" project with the same name "SilverligthPlatformer"
  • Add all (except "Program.cs") c# source files from XNA project main folder to Silverlight project
  • In Silverlight project create a new folder and name it "Content"
  • In a newly created folder copy selected content files from XNA project "SharedContent" and "HighResolutionContent" folders. Copy font file "Peric.ttf" to "Content\Fonts" folder. You should finish with folder structure same like this:

folders.png
  • Add all previously copied files to your Silverlight project, and set properties to "Content/Do not copy".
  • Open file "Content\Fonts\Hud.spritefont" and change:
from
<FontName>Peric</FontName>

to:
<FontName>Content/Fonts/Peric.ttf#Pericles</FontName>
  • For the fonts embedded in Silverlight plugin just enter the font name like "Verdana", "Tahoma", etc. Be aware that you can't distribute font files if you don't have rights to do this.
  • Download Xn4Sl.dll library or project source files and add its reference to your Silverlight project.
  • In all source files change using statements and references from Microsoft.XNA.Framework... to Xn4Sl.Framework...
  • In PlatformerGame.cs->LoadNextLevel() change:
from
    if (File.Exists(levelPath))

to
    if (this.Content.FileExist(levelPath))
  • In Level.cs change: "using System.IO;" to: "using Xn4Sl.Framework.IO;"
  • Finally change App.xaml.cs->Application_Startup method:
from:
    this.RootVisual = new Page();

to:
    var game = new SilverlightPlatformer.PlatformerGame();
    this.RootVisual = game;
    game.Run();

Adjust some constant values like TargetFrameRate, MoveAcceleration, MaxMoveSpeed etc.

To read more about XNA game development visit Microsoft XNA site.

Last edited May 15, 2009 at 10:49 PM by raffsky, version 18