Game Development Community

Blaster Tutorial Problem - GameInstance definition

by Erol Oksuz · in Torque X 2D · 09/03/2008 (1:47 am) · 2 replies

Almost made it to the end, but I've encountered this in my EnemyAIComponent.cs:

Error 6
'Microsoft.Xna.Framework.Game' does not contain a definition for 'GameInstance' C:\projects\xna\testgame\testgame\Game\EnemyAIComponent.cs

for the lines

float TargetX = Game.GameInstance.Player.Position.X;

I don't know if it's related to this snippet in Game.cs

static public Game GameInstance
        {
            get { return _myGame; }
        }

thanks!


There were a few other issues earlier that were cleared up by a bit of hunting around on here. Is it possible to have the Tutorials added to the wiki, so we can update them with clearer instructions as needed?

About the author

Recent Threads


#1
09/03/2008 (2:50 pm)
This looks like it is to do with namespaces.

Game is part of the StarterGame2D namespace but also part of the Microsoft.XNA.Framework namespace. The compiler is not looking at the StarterGame2D namespace.

What namespace is your EnemyAIComponent class defined in (should be at the top of you code after the using statements)
#2
09/03/2008 (10:56 pm)
Thank you, Richard!

It was set to:

namespace GarageGames.Torque.T2DComponents

so I changed it to

namespace StarterGame2D

and it works!

I had originally added the items under Torque, got some protected errors, moved them to Game, but didn't realize the namespace was now incorrect. Thanks again!