- In Visual Studio, Choose new project > Silverlight > Silverlight Application. Click NO to the prompt about "Host as a new web site"
- Open MainPage.xaml and add the following the <UserControl> tag as an atribute:
xmlns:game="clr-namespace:[your project name here]"
- In MainPage.xaml, Add the following to the <Grid> contents:
<Canvas>
<game:Game2D x:Name="Game1"/>
</Canvas>
- Right click on project name in Solution Explorer > add > class...
Call the class
Game2D.cs
- In Game2D.cs, replace the "
using
..." lines with:
using System;
using System.Collections.Generic;
using System.Linq;
#if(SILVERLIGHT)
using SilverArcade.SilverSprite;
using SilverArcade.SilverSprite.Audio;
using SilverArcade.SilverSprite.Content;
using SilverArcade.SilverSprite.GamerServices;
using SilverArcade.SilverSprite.Graphics;
using SilverArcade.SilverSprite.Input;
using SilverArcade.SilverSprite.Media;
using SilverArcade.SilverSprite.Storage;
#else
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
#endif
- In Game2D.cs, replace the class declaration with:
public class Game2D : SilverArcade.SilverSprite.Game
- In Game2D.cs, Add global variables:
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
- In Game2D.cs, add constructor:
public Game2D()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.PreferredBackBufferWidth = 1000;
graphics.PreferredBackBufferHeight = 600;
}
- In Game2D.cs, Add initialize method:
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
- In Game2D.cs, Add loadcontent method:
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
- In Game2D.cs, Add unloadcontent method:
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
- In Game2D.cs, Add update method:
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
- In Game2D.cs, Add draw method:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Gray);
spriteBatch.Begin();
spriteBatch.End();
base.Draw(gameTime);
}
- Add silversprite.dll to project by right clicking on references and add existing item and choose your silversprite.dll (probably put this in debug or release folder or wherever).