One of the key differences between Silverlight and other platforms is its ability to setup its UI declaratively through the usage of something called Xaml (eXtensible Markup Language). Balder takes advantage of this, and is in fact the only way to use the engine (Previous versions had a way through something called TargetDevice.Initialize<>(), this is marked as obsolete and will be removed in a future version).

MainPage

When you have created your Silverlight project, you have a MainPage.xaml, it should look something like this:

<UserControl
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   x:Class="MyApplication.MainPage">
   <Grid>
   </Grid>
</UserControl>

Controls

Balder comes with a set of controls that reflects the features available at the Core of Balder. These can be found in the component called "Balder.Silverlight" inside the namespace "Balder.Silverlight.Controls".
To use the controls, one needs to add a namespace declaration referencing this namespace, this declaration is put at the top of your page or UserControl.

Add the following attribute in your UserControl start tag:

xmlns:Execution="clr-namespace:Balder.Execution;assembly=Balder"

Your result should be something like this:

<UserControl
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   xmlns:Execution="clr-namespace:Balder.Execution;assembly=Balder"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   x:Class="MyApplication.MainPage">
   <Grid>
   </Grid>
</UserControl>

Game control

In order to get anything rendered you need to add a Game control. The game control is the one in charge of all the content, events and game logic. If you are targeting multiple platforms, you also use this to reference the common game class (see Silverlight Game Class for more information).

It is very important that you specify the exact width and height of this control, as Balder does not support dynamic resizing at the moment.

Add the following inside the Grid or other container in your page/UserControl
<Execution:Game Width="800" Height="600"/>

The result should be something like this:

<UserControl
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   xmlns:Execution="clr-namespace:Balder.Execution;assembly=Balder"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   x:Class="MyApplication.MainPage">
   <Grid>
      <Execution:Game Width="800" Height="600"/>
   </Grid>
</UserControl>

Last edited Jul 26, 2010 at 10:19 PM by adept, version 6

Comments

No comments yet.