<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Using the Game State Management Sample</title>
	<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/</link>
	<description>Game Development Demystified!</description>
	<pubDate>Wed, 27 Aug 2008 23:46:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: javi</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-353</link>
		<dc:creator>javi</dc:creator>
		<pubDate>Mon, 11 Aug 2008 10:35:10 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-353</guid>
		<description>Thanks for reply Nazeeh!, 

Unfortunately ToggleFullScreen() is a method  from GraphicsDeviceManager (not from GraphicsDevice), and is not way call it from ScreenManager.Game (that I knows..)

Finally I found a way to resolve this, in ScreenManager I have created a new attribute: 
public GraphicsDeviceManager graphics;

And change constructor this way:
public ScreenManager(Game game,GraphicsDeviceManager graphics) : base(game)
{
        this.graphics = graphics;
}

To toggle full screen I call this in GameplayScreen: ScreenManager.graphics.ToggleFullScreen();
I don't know if is the best way, but it works!</description>
		<content:encoded><![CDATA[<p>Thanks for reply Nazeeh!, </p>
<p>Unfortunately ToggleFullScreen() is a method  from GraphicsDeviceManager (not from GraphicsDevice), and is not way call it from ScreenManager.Game (that I knows..)</p>
<p>Finally I found a way to resolve this, in ScreenManager I have created a new attribute:<br />
public GraphicsDeviceManager graphics;</p>
<p>And change constructor this way:<br />
public ScreenManager(Game game,GraphicsDeviceManager graphics) : base(game)<br />
{<br />
        this.graphics = graphics;<br />
}</p>
<p>To toggle full screen I call this in GameplayScreen: ScreenManager.graphics.ToggleFullScreen();<br />
I don&#8217;t know if is the best way, but it works!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nazeeh</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-352</link>
		<dc:creator>nazeeh</dc:creator>
		<pubDate>Sun, 10 Aug 2008 17:33:26 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-352</guid>
		<description>Hey Javi,

I am not looking at the code right now, but every gameplay screen should have a ScreenManager instance in it. You should be able to either find a GraphicsDevice on that ScreenManager somewhere, or a Game instance which has a GraphicsDevice on it. Something like ScreenManager.Game.GraphicsDevice.ToggleFullscreen();

Let me know if you still have issues and I'll look at the code and give you a more accurate answer :)</description>
		<content:encoded><![CDATA[<p>Hey Javi,</p>
<p>I am not looking at the code right now, but every gameplay screen should have a ScreenManager instance in it. You should be able to either find a GraphicsDevice on that ScreenManager somewhere, or a Game instance which has a GraphicsDevice on it. Something like ScreenManager.Game.GraphicsDevice.ToggleFullscreen();</p>
<p>Let me know if you still have issues and I&#8217;ll look at the code and give you a more accurate answer :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: javi</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-351</link>
		<dc:creator>javi</dc:creator>
		<pubDate>Sun, 10 Aug 2008 09:25:41 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-351</guid>
		<description>Hi nazeeh, I'm trying to access graphics.ToggleFullScreen(); or graphics.IsFullScreen from the GameplayScreen class, but can not define a new GraphicsDeviceManager this way:
graphics = new GraphicsDeviceManager (this);

I'm a little confused, i don't know the exactly in which class I can introduce code so when you press a button changes between full-screen to window and vice versa.</description>
		<content:encoded><![CDATA[<p>Hi nazeeh, I&#8217;m trying to access graphics.ToggleFullScreen(); or graphics.IsFullScreen from the GameplayScreen class, but can not define a new GraphicsDeviceManager this way:<br />
graphics = new GraphicsDeviceManager (this);</p>
<p>I&#8217;m a little confused, i don&#8217;t know the exactly in which class I can introduce code so when you press a button changes between full-screen to window and vice versa.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benzino</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-341</link>
		<dc:creator>Benzino</dc:creator>
		<pubDate>Tue, 08 Jul 2008 08:33:20 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-341</guid>
		<description>Thanks for the reply and great post!</description>
		<content:encoded><![CDATA[<p>Thanks for the reply and great post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nazeeh</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-340</link>
		<dc:creator>nazeeh</dc:creator>
		<pubDate>Tue, 08 Jul 2008 02:22:42 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-340</guid>
		<description>Where are you doing this? I am guessing you're running this in a constructor of one of your Screens. If you are, then ScreenManager will be null at the time of construction. This is because the method that creates your screen first instantiates it THEN it assigns it a copy of ScreenManager. 

If you look in this post's comments, someone asked a similar question. I told them how they can have an Initialize method added to Screens where they can put code like this. Then you would modify the method that creates screens and have it call the Init function after assigning a ScreenManager to the class.</description>
		<content:encoded><![CDATA[<p>Where are you doing this? I am guessing you&#8217;re running this in a constructor of one of your Screens. If you are, then ScreenManager will be null at the time of construction. This is because the method that creates your screen first instantiates it THEN it assigns it a copy of ScreenManager. </p>
<p>If you look in this post&#8217;s comments, someone asked a similar question. I told them how they can have an Initialize method added to Screens where they can put code like this. Then you would modify the method that creates screens and have it call the Init function after assigning a ScreenManager to the class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benzino</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-339</link>
		<dc:creator>Benzino</dc:creator>
		<pubDate>Mon, 07 Jul 2008 17:00:57 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-339</guid>
		<description>Hey, Great post, but im kinda struck.

Alot of the game we are working on is nearly complete (or in advanced stages) and we are only now adding the game menu System. This is proving to me a total nightmare, with classes needed to be changed nearly everywhere (as we were accessing vars from the Game1 class). Anyway, we need access to the GraphicsDeviceManager, but the following code does not work:

if(graphics == null)
{
graphics = new GraphicsDeviceManager(ScreenManager.Game);
}

Any Ideas?</description>
		<content:encoded><![CDATA[<p>Hey, Great post, but im kinda struck.</p>
<p>Alot of the game we are working on is nearly complete (or in advanced stages) and we are only now adding the game menu System. This is proving to me a total nightmare, with classes needed to be changed nearly everywhere (as we were accessing vars from the Game1 class). Anyway, we need access to the GraphicsDeviceManager, but the following code does not work:</p>
<p>if(graphics == null)<br />
{<br />
graphics = new GraphicsDeviceManager(ScreenManager.Game);<br />
}</p>
<p>Any Ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ricardo</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-338</link>
		<dc:creator>Ricardo</dc:creator>
		<pubDate>Fri, 04 Jul 2008 19:14:45 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-338</guid>
		<description>IN my last post where i wrote "public virtual void HandleCamera(FirstPersonCamera camera) { }" IT SHOULD BE :

"public virtual void HandleSound(SoundManager sound) { }"

Sorry about that.</description>
		<content:encoded><![CDATA[<p>IN my last post where i wrote &#8220;public virtual void HandleCamera(FirstPersonCamera camera) { }&#8221; IT SHOULD BE :</p>
<p>&#8220;public virtual void HandleSound(SoundManager sound) { }&#8221;</p>
<p>Sorry about that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ricardo</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-337</link>
		<dc:creator>Ricardo</dc:creator>
		<pubDate>Wed, 02 Jul 2008 21:11:02 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-337</guid>
		<description>Regarding what mozolio said about audio, I solved that problem other way.

In "GameScreen" class i added : 
public virtual void HandleCamera(FirstPersonCamera camera) { }

So in this way i can override the method in a similar way we do with HandleInput, but for audio, so that in the class you want to manage your audio you simply call:

public override void HandleSound(SoundManager sound)
        {
            sound.Play("sound_file");
        }

Off course you need a "SoundManager" class that provides the "play" method, but normal tutorials for XNA audio usually show how to do it.

This worked for me :), but could be better ways.</description>
		<content:encoded><![CDATA[<p>Regarding what mozolio said about audio, I solved that problem other way.</p>
<p>In &#8220;GameScreen&#8221; class i added :<br />
public virtual void HandleCamera(FirstPersonCamera camera) { }</p>
<p>So in this way i can override the method in a similar way we do with HandleInput, but for audio, so that in the class you want to manage your audio you simply call:</p>
<p>public override void HandleSound(SoundManager sound)<br />
        {<br />
            sound.Play(&#8221;sound_file&#8221;);<br />
        }</p>
<p>Off course you need a &#8220;SoundManager&#8221; class that provides the &#8220;play&#8221; method, but normal tutorials for XNA audio usually show how to do it.</p>
<p>This worked for me :), but could be better ways.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-300</link>
		<dc:creator>J</dc:creator>
		<pubDate>Thu, 24 Apr 2008 22:54:43 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-300</guid>
		<description>thanks that did explain things. I am using a bullet array based on one of the tutorials, the whole program works on its own (with everyhting in game.cs) but when i put it  into the  gameplay screen i get an "object reference not set to an instance of an object" error in

                  if (ship.isActive)
                  {
                      // Draw all the active bullets on screen
                      for (int k = 0; k &#60; GameConstants.NumBullets; k++)
                      {
                          if (bulletList[k].isActive)
                          {
                              Matrix bulletTransform =
                                Matrix.CreateTranslation(bulletList[k].position);
                              DrawModel(bulletModel, bulletTransform, bulletTransforms);

                          }
                      }

                  } 
for the  if (bulletList[k].isActive) part. but i have set it at the top with

 Bullet[] bulletList = new Bullet[GameConstants.NumBullets];

the only real difference with my original game and this one is i put the i put the initialize stuff in the constructor and i didnt use UpdateInput method for the controls used the hanldeinput instead. If i take evrythhing to do with firing or bulletList out the game works fine, the badguys and the player are drawn onscreen so it is definatly to do with that. 

 Model bulletModel;
        Matrix[] bulletTransforms;
        Bullet[] bulletList = new Bullet[GameConstants.NumBullets];
is defined as follows. I hate to keep bothering you but this is the only place that get a useful answer to my questions.</description>
		<content:encoded><![CDATA[<p>thanks that did explain things. I am using a bullet array based on one of the tutorials, the whole program works on its own (with everyhting in game.cs) but when i put it  into the  gameplay screen i get an &#8220;object reference not set to an instance of an object&#8221; error in</p>
<p>                  if (ship.isActive)<br />
                  {<br />
                      // Draw all the active bullets on screen<br />
                      for (int k = 0; k &lt; GameConstants.NumBullets; k++)<br />
                      {<br />
                          if (bulletList[k].isActive)<br />
                          {<br />
                              Matrix bulletTransform =<br />
                                Matrix.CreateTranslation(bulletList[k].position);<br />
                              DrawModel(bulletModel, bulletTransform, bulletTransforms);</p>
<p>                          }<br />
                      }</p>
<p>                  }<br />
for the  if (bulletList[k].isActive) part. but i have set it at the top with</p>
<p> Bullet[] bulletList = new Bullet[GameConstants.NumBullets];</p>
<p>the only real difference with my original game and this one is i put the i put the initialize stuff in the constructor and i didnt use UpdateInput method for the controls used the hanldeinput instead. If i take evrythhing to do with firing or bulletList out the game works fine, the badguys and the player are drawn onscreen so it is definatly to do with that. </p>
<p> Model bulletModel;<br />
        Matrix[] bulletTransforms;<br />
        Bullet[] bulletList = new Bullet[GameConstants.NumBullets];<br />
is defined as follows. I hate to keep bothering you but this is the only place that get a useful answer to my questions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nazeeh</title>
		<link>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-299</link>
		<dc:creator>nazeeh</dc:creator>
		<pubDate>Wed, 23 Apr 2008 22:31:48 +0000</pubDate>
		<guid>http://www.nazspace.com/wp/2008/02/04/using-the-game-state-management-sample/#comment-299</guid>
		<description>You should sit far away from a wall dude ;)

Alright...check out comment #14 and 15 on this thread. You'll find your answer!</description>
		<content:encoded><![CDATA[<p>You should sit far away from a wall dude ;)</p>
<p>Alright&#8230;check out comment #14 and 15 on this thread. You&#8217;ll find your answer!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
