<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx</link><description>I used the Game State Management sample as a basis for my AppWeek game . I also used several samples that are implemented as a DrawableGameComponent ( bloom , lensflare , 3D particles ). Herein lies a dilemma: Components are global to the entire game</description><dc:language>en</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#10175491</link><pubDate>Thu, 16 Jun 2011 22:12:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10175491</guid><dc:creator>BlueRaja</dc:creator><description>&lt;p&gt;The reason there is no FindComponent already is that components are not supposed to reference each other directly. &amp;nbsp;If you really need a component to be accessible from other components, you should create an interface containing only the things you want accessible, and add it as a service; see &lt;a rel="nofollow" target="_new" href="http://gamedev.stackexchange.com/questions/13723/xna-static-classes-from-game-libraries-executing-after-content-pipeline-extensi/13763#13763"&gt;gamedev.stackexchange.com/.../13763&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A class-instance can be both a component and a service.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10175491" width="1" height="1"&gt;</description></item><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9811272</link><pubDate>Wed, 01 Jul 2009 18:33:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9811272</guid><dc:creator>Alvin Tang</dc:creator><description>&lt;p&gt;Hey Shawn,&lt;/p&gt;
&lt;p&gt;Thanks! Nice fix. &amp;nbsp;Got it up and running as you suggested. &amp;nbsp;Looks sweet!&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9811272" width="1" height="1"&gt;</description></item><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9811220</link><pubDate>Wed, 01 Jul 2009 18:02:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9811220</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;Hey Alvin, I actually ran into the exact same issue!&lt;/p&gt;
&lt;p&gt;The problem is that the lensflare draw method actually does two unrelated things: first it checks visibility with the occlusion query, then it draws the flares. We want to draw the flares over the top of the bloom, but the visibility query needs to take place before the bloom rendering, as bloom will destroy the depth buffer data that it depends on to detect occlusion.&lt;/p&gt;
&lt;p&gt;My solution was to split up the LensFlareComponent.Draw method, so I could call the first part of it (up to and including the UpdateOcclusion method) before bloom, and then the remaining part (DrawGlow and DrawFlares) after the bloom.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9811220" width="1" height="1"&gt;</description></item><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9810459</link><pubDate>Wed, 01 Jul 2009 10:36:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9810459</guid><dc:creator>Alvin Tang</dc:creator><description>&lt;p&gt;Nice stuff! &amp;nbsp;I've been inspired and am putting together my own mashup this week during my students' test week.&lt;/p&gt;
&lt;p&gt;I had an issue getting the Bloom and Lens Flare components to play well together though. &amp;nbsp;Using something similar to what you have above, by doing this&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DrawModel(shipModel, ship.World);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DrawModel(groundModel, Matrix.Identity);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Bloom the entire scene that we've just drawn.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bloom.Draw(gameTime);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lensFlare.View = camera.View;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lensFlare.Projection = camera.Projection;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lensFlare.Draw(gameTime);&lt;/p&gt;
&lt;p&gt;The lens flare component doesn't get blocked out when a 3D object covers the light source.&lt;/p&gt;
&lt;p&gt;Doing the following:&lt;/p&gt;
&lt;p&gt; DrawModel(shipModel, ship.World);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DrawModel(groundModel, Matrix.Identity);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lensFlare.View = camera.View;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lensFlare.Projection = camera.Projection;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lensFlare.Draw(gameTime);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Bloom the entire scene that we've just drawn.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bloom.Draw(gameTime);&lt;/p&gt;
&lt;p&gt;... blurs the lens flare as well, but gives allows the flare and light source to be blocked when an object comes between that and the camera.&lt;/p&gt;
&lt;p&gt;Am I missing something or is there no elegant fix? &amp;nbsp;I'm thinking it's the former. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9810459" width="1" height="1"&gt;</description></item><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9799692</link><pubDate>Tue, 23 Jun 2009 19:11:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9799692</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;Simon: I guess this comes down to how much we want the sample to be just a starting framework, versus how much we want to polish it into something that can be used as-is. The tension here is between making it as robust and powerful as possible, but not adding so much complexity that people can't understand it enough to build their own stuff on top of it. I keep going back and forth as to which goal I think is more important!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9799692" width="1" height="1"&gt;</description></item><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9799109</link><pubDate>Tue, 23 Jun 2009 12:15:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9799109</guid><dc:creator>Simon (Darkside) Jackson</dc:creator><description>&lt;p&gt;That's great stuff Shawn, do you think you'll be able to update the GSM sample with everything you've discovered. &amp;nbsp;I know the APPWeek stuff is usually private but I think this update should be ok?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9799109" width="1" height="1"&gt;</description></item><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9793569</link><pubDate>Sat, 20 Jun 2009 15:35:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9793569</guid><dc:creator>Alponious</dc:creator><description>&lt;p&gt;Thanks for posting this. &amp;nbsp;I've been struggling with GamestateManagement and using Game Components.&lt;/p&gt;
&lt;p&gt;One additional problem you run into is if you add your Game Components in GamePlayScreen.cs, every time you cycle back to the main menu from your game and then go back to the game, you re-add those components to your components collection. &amp;nbsp;If you check your component count, you'll see that number just grow every time you exit to main menu and back to game. &amp;nbsp;I would assume, over time, that would lead to a crash. &amp;nbsp;One solution is to Clear all components when you unload content in GamePlayScreen.cs. &amp;nbsp;But that cleared components I did not want to clear. &amp;nbsp;So now I manually remove all components that I added in GamePlayScreen but again....it's just a pain.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9793569" width="1" height="1"&gt;</description></item><item><title>PBF</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9775956</link><pubDate>Thu, 18 Jun 2009 16:12:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9775956</guid><dc:creator>lance7</dc:creator><description>&lt;p&gt;I have tried it. It works fine. And it is simple like all great things. Thanks for sharing&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9775956" width="1" height="1"&gt;</description></item><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9774664</link><pubDate>Thu, 18 Jun 2009 11:56:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9774664</guid><dc:creator>NRadford</dc:creator><description>&lt;p&gt;I've also hit the problems you describe, and though what you've done is great in a rush. It feels like a hack to me. &lt;/p&gt;
&lt;p&gt;There really should be a library for this. I feel a new project coming on. &amp;quot;XNAContrib&amp;quot; anyone? :P&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9774664" width="1" height="1"&gt;</description></item><item><title>re: Game State Management and DrawableGameComponent</title><link>http://blogs.msdn.com/b/shawnhar/archive/2009/06/17/game-state-management-and-drawablegamecomponent.aspx#9771474</link><pubDate>Thu, 18 Jun 2009 04:40:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9771474</guid><dc:creator>Kevin Gadd</dc:creator><description>&lt;p&gt;Nice trick. I've actually been manually converting a bunch of GameComponents to unique types because of the drawing hassles you describe - I hadn't ever thought of making them invisible and manually issuing the Draw calls.&lt;/p&gt;
&lt;p&gt;I'll have to see if I can apply this to my game; might save me some effort.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9771474" width="1" height="1"&gt;</description></item></channel></rss>