This project is read-only.

Problems getting my game running

Apr 20, 2009 at 7:53 PM
Edited Apr 20, 2009 at 7:55 PM
Hello,
I followed the instruction you give on the home page and I have added the SilverArcade.SilverSprite library and the Game1.cs and the Program.cs. But when I try to edit the page.xaml, it says (I try to translate it in English): The CLR namespace was not defined. The URI of the CLR namespace refers to the namespace "EmptyTestGame", which was not found in the assembly. I have added the code files to the project and the namespace's name is EmptyTestGame. The second error is that thetype Game1 was not found but I think that's because the compiler doesn't find the namespace. I use Visual Web Developer 2008 EE and haven't got any experience with it. I would appreciate a wizard which converts existing XNA projects into Silverlight projects.
Apr 20, 2009 at 10:24 PM
Sorry you're having trouble, there is a wizard in the works. Could you post the contents of your Page.xaml please so I can take a look?

Bill
Apr 22, 2009 at 8:27 AM
hi, i think i am having the same issue.I made an XNA game and cleared up all the errors except this namespace issue. this is probably the simplest one too haha. im still learning though, thanks for all your work, here is my xaml code

<UserControl x:Class="SilverlightApplication1.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <Canvas>
            <YeOldeDiceGame:Game x:Name="game"/>
        </Canvas>
    </Grid>
</UserControl>

Error    1    'YeOldeDiceGame' is an undeclared namespace.    
Error    2    The type 'YeOldeDiceGame:Game' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.   

this is the first time i used silverlight too. please help.

Apr 22, 2009 at 1:10 PM
Ok yes it's as I thought. You need an xmlns entry at the top for YeOldeDiceGame. If you type xmlns:YeOldeDiceGame= you should get autocomplete where you can select the correct assembly and namespace. Think of this like an include statement for XAML. You can look at the samples in the source tree for how this looks. I'll be doing a new release in the next few days which includes source code but for now the code in the source tree is stable.

Bill
Apr 22, 2009 at 4:31 PM
Edited Apr 22, 2009 at 4:32 PM
So my Page.xaml looks like this now:

    <UserControl   xmlns:EmptyTestGame="clr-namespace:SilverSpriteTest"  x:Class="SilverSpriteTest.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300" xmlns:game="clr-namespace:EmptyTestGame">
    <Grid x:Name="LayoutRoot" Background="White">
        <Canvas>
            <game:Game1 x:Name="game"/>
        </Canvas>
    </Grid>
</UserControl>

but I get still the same errors. My namespace is "EmptyTestGame" and the game class is Game1.

btw: Is it normal that the IntelliSense autocomplete doesn't work in the Game1.cs and the XNA types (like SpriteBatch etc.) are not marked in blue? That's the case in my project and I think it's a bit strange...
Apr 22, 2009 at 5:44 PM
Edited Apr 22, 2009 at 5:48 PM
ok my game is running, im sure it still has lots of bugs and things but i can probably fix those

heres my page.xaml

<UserControl
    x:Class="SilverlightApplication1.Page"
    xmlns:game="clr-namespace:YeOldeDiceGame"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <Canvas>
            <game:Game x:Name="game"/>
        </Canvas>
    </Grid>
</UserControl>

maybe i was doing this wrong, but in my Game.cs file I changed some code
yoursnakesample had Game1 instead of SnakeGame here. I used to have YeOldeDiceGame there instead of Game.

public class Game : SilverArcade.SilverSprite.Game  
    {
      stuff;
     }

the Game.cs constructor
public Game()     // used to be public YeOldeDiceGame()
        {
          stuff;
        }

i also had to comment out the main method in my Game.cs file
/*   static class Program
    {
        static void Main()
        {
            using (Game game = new Game())
            {
                game.Run();
            }
        }
    }*/