Intermission #10–(Part 2) lets tax the brain
Apologies, had to split the post do to some technical issues on teh XNA-UK site, were working hard to resolve that but fo rnow, here’s the continuation of the Intermission 10 post.
Source updated for Final combined update project for GS 4.0 project here on Codeplex (Windows and WP7)
Putting it all in place
Now at the moment nothing happens and we still have a few errors showing up in our project so lets finish it up and get it running.
In the particle manager we need to update and add a few things:
- Replace all references to “ParticleEmitter” with “ParticleEffect” so we are using the new effect we have (mainly in all the pool declarations so that it is using the new effect generator)
- Replace statements that refer to “Active” with “isActive” (this is because I wanted to change Robin’s code as little as possble, you could just rename the isActive in the particle classed to Active if you wished), this is mainly in the update and Draw functions
- Add a new variable at the start of the class just after the textures dictionary for “SpriteBatch m_batch;”. this just a quick way of getting access to the main game spritebatch without having to create another and pass this on to the Effect generator to draw the particles (since previously it was the manager that drew the particles)
- Alter the constructor for the Particle manager class like so (which accepts the sprite batch from the game class and stored it for use later):
1 |
<pre style="margin: 0em; width: 100%; font-family: consolas,"Courier New",courier,monospace; font-size: 12px; background-color: rgb(251, 251, 251);"> 1: <span style="color: rgb(0, 0, 255);">public</span> ParticleManager(Game game, <span style="color: rgb(0, 0, 255);">ref</span> SpriteBatch batch) |
1 |
2: : <span style="color: rgb(0, 0, 255);">base</span>(game) |
1 |
3: { |
1 |
4: m_batch = batch; |
1 |
5: <span style="color: rgb(0, 128, 0);">// TODO: Construct any child components here</span> |
1 |
6: } |
1 |
7: |
- Change the line in the update function from “penode.Item.Update(dt);” to “penode.Item.Update(gameTime);”. Again this was to accommodate Robin’s code.
- Remove the Lines with “StarTrooperGame.spriteBatch.Begin” and “StarTrooperGame.spriteBatch.End” as we are now using the stored SpriteBatch reference
- lastly we remove the draw logic inside the ForEach loop for the emitters completely and replace it with (basically removing the “foreach (Particle p in pe.particles)” section):
1 |
<pre style="margin: 0em; width: 100%; font-family: consolas,"Courier New",courier,monospace; font-size: 12px; background-color: rgb(251, 251, 251);"> 1: m_batch.Begin(SpriteSortMode.Texture, pe.SpriteBlendMode); |
1 |
2: |
1 |
3: pe.Draw(m_textures[pe.TextureName],m_batch); |
1 |
4: m_batch.End(); |
1 |
5: |
Almost done, that fixes up the particle manager but we still need to launch an effect. So if you now open up the Game class and replace it with the following (Don’t forget to rename the namespace back to your your original projects namespace):
1 |
<pre style="margin: 0em; width: 100%; font-family: consolas,"Courier New",courier,monospace; font-size: 12px; background-color: rgb(251, 251, 251);"> 1: <span style="color: rgb(0, 0, 255);">using</span> System; |
1 |
2: <span style="color: rgb(0, 0, 255);">using</span> System.Collections.Generic; |
1 |
3: <span style="color: rgb(0, 0, 255);">using</span> System.Linq; |
1 |
4: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework; |
1 |
5: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Audio; |
1 |
6: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Content; |
1 |
7: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.GamerServices; |
1 |
8: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Graphics; |
1 |
9: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Input; |
1 |
10: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Input.Touch; |
1 |
11: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Media; |
1 |
12: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Phone.Shell; |
1 |
13: |
1 |
14: <span style="color: rgb(0, 0, 255);">namespace</span> TouchScreenPOC |
1 |
15: { |
1 |
16: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
17: <span style="color: rgb(128, 128, 128);">/// This is the main type for your game</span> |
1 |
18: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
19: <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">class</span> Game1 : Microsoft.Xna.Framework.Game |
1 |
20: { |
1 |
21: GraphicsDeviceManager graphics; |
1 |
22: SpriteBatch spriteBatch; |
1 |
23: SpriteFont spriteFont; |
1 |
24: TouchCollection touches; |
1 |
25: |
1 |
26: <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">static</span> ParticleManager ParticleManager; |
1 |
27: |
1 |
28: <span style="color: rgb(0, 0, 255);">public</span> Game1() |
1 |
29: { |
1 |
30: graphics = <span style="color: rgb(0, 0, 255);">new</span> GraphicsDeviceManager(<span style="color: rgb(0, 0, 255);">this</span>); |
1 |
31: Content.RootDirectory = "<span style="color: rgb(139, 0, 0);">Content</span>"; |
1 |
32: |
1 |
33: <span style="color: rgb(0, 128, 0);">// Frame rate is 30 fps by default for Windows Phone.</span> |
1 |
34: TargetElapsedTime = TimeSpan.FromTicks(333333); |
1 |
35: |
1 |
36: <span style="color: rgb(0, 128, 0);">// Pre-autoscale settings.</span> |
1 |
37: graphics.PreferredBackBufferWidth = 480; |
1 |
38: graphics.PreferredBackBufferHeight = 800; |
1 |
39: |
1 |
40: } |
1 |
41: |
1 |
42: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
43: <span style="color: rgb(128, 128, 128);">/// Allows the game to perform any initialization it needs to before starting to run.</span> |
1 |
44: <span style="color: rgb(128, 128, 128);">/// This is where it can query for any required services and load any non-graphic</span> |
1 |
45: <span style="color: rgb(128, 128, 128);">/// related content. Calling base.Initialize will enumerate through any components</span> |
1 |
46: <span style="color: rgb(128, 128, 128);">/// and initialize them as well.</span> |
1 |
47: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
48: <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> Initialize() |
1 |
49: { |
1 |
50: <span style="color: rgb(0, 128, 0);">// TODO: Add your initialization logic here</span> |
1 |
51: spriteBatch = <span style="color: rgb(0, 0, 255);">new</span> SpriteBatch(GraphicsDevice); |
1 |
52: ParticleManager = <span style="color: rgb(0, 0, 255);">new</span> ParticleManager(<span style="color: rgb(0, 0, 255);">this</span>, <span style="color: rgb(0, 0, 255);">ref</span> spriteBatch); |
1 |
53: <span style="color: rgb(0, 0, 255);">this</span>.Components.Add(ParticleManager); |
1 |
54: |
1 |
55: <span style="color: rgb(0, 0, 255);">base</span>.Initialize(); |
1 |
56: } |
1 |
57: |
1 |
58: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
59: <span style="color: rgb(128, 128, 128);">/// LoadContent will be called once per game and is the place to load</span> |
1 |
60: <span style="color: rgb(128, 128, 128);">/// all of your content.</span> |
1 |
61: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
62: <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> LoadContent() |
1 |
63: { |
1 |
64: <span style="color: rgb(0, 128, 0);">// Create a new SpriteBatch, which can be used to draw textures.</span> |
1 |
65: spriteFont = Content.Load<SpriteFont>("<span style="color: rgb(139, 0, 0);">SpriteFont1</span>"); |
1 |
66: <span style="color: rgb(0, 128, 0);">// TODO: use this.Content to load your game content here</span> |
1 |
67: } |
1 |
68: |
1 |
69: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
70: <span style="color: rgb(128, 128, 128);">/// UnloadContent will be called once per game and is the place to unload</span> |
1 |
71: <span style="color: rgb(128, 128, 128);">/// all content.</span> |
1 |
72: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
73: <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> UnloadContent() |
1 |
74: { |
1 |
75: <span style="color: rgb(0, 128, 0);">// TODO: Unload any non ContentManager content here</span> |
1 |
76: } |
1 |
77: |
1 |
78: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
79: <span style="color: rgb(128, 128, 128);">/// Allows the game to run logic such as updating the world,</span> |
1 |
80: <span style="color: rgb(128, 128, 128);">/// checking for collisions, gathering input, and playing audio.</span> |
1 |
81: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
82: <span style="color: rgb(128, 128, 128);">/// <param name="gameTime">Provides a snapshot of timing values.</param></span> |
1 |
83: <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> Update(GameTime gameTime) |
1 |
84: { |
1 |
85: <span style="color: rgb(0, 128, 0);">// Allows the game to exit</span> |
1 |
86: <span style="color: rgb(0, 0, 255);">if</span> (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) |
1 |
87: <span style="color: rgb(0, 0, 255);">this</span>.Exit(); |
1 |
88: |
1 |
89: <span style="color: rgb(0, 128, 0);">// TODO: Add your update logic here</span> |
1 |
90: touches = TouchPanel.GetState(); |
1 |
91: |
1 |
92: <span style="color: rgb(0, 0, 255);">foreach</span> (TouchLocation t <span style="color: rgb(0, 0, 255);">in</span> touches) |
1 |
93: { |
1 |
94: <span style="color: rgb(0, 0, 255);">switch</span> (t.State) |
1 |
95: { |
1 |
96: <span style="color: rgb(0, 0, 255);">case</span> TouchLocationState.Pressed: |
1 |
97: InitiliseEffect(t.Position); |
1 |
98: <span style="color: rgb(0, 0, 255);">break</span>; |
1 |
99: <span style="color: rgb(0, 0, 255);">case</span> TouchLocationState.Moved: |
1 |
100: <span style="color: rgb(0, 0, 255);">break</span>; |
1 |
101: <span style="color: rgb(0, 0, 255);">case</span> TouchLocationState.Released: |
1 |
102: <span style="color: rgb(0, 0, 255);">break</span>; |
1 |
103: <span style="color: rgb(0, 0, 255);">default</span>: |
1 |
104: <span style="color: rgb(0, 0, 255);">break</span>; |
1 |
105: } |
1 |
106: } |
1 |
107: <span style="color: rgb(0, 0, 255);">base</span>.Update(gameTime); |
1 |
108: } |
1 |
109: |
1 |
110: <span style="color: rgb(0, 0, 255);">void</span> InitiliseEffect(Vector2 Location) |
1 |
111: { |
1 |
112: ParticleEffectExample effect = <span style="color: rgb(0, 0, 255);">new</span> ParticleEffectExample(); |
1 |
113: effect.Initialize(Location.X,Location.Y,1); |
1 |
114: effect.effectVelocity = <span style="color: rgb(0, 0, 255);">new</span> Vector2(0, 5); |
1 |
115: effect.effectAcceleration = <span style="color: rgb(0, 0, 255);">new</span> Vector2(0, 1f); |
1 |
116: ParticleManager.Add(effect); |
1 |
117: } |
1 |
118: |
1 |
119: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
120: <span style="color: rgb(128, 128, 128);">/// This is called when the game should draw itself.</span> |
1 |
121: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
122: <span style="color: rgb(128, 128, 128);">/// <param name="gameTime">Provides a snapshot of timing values.</param></span> |
1 |
123: <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> Draw(GameTime gameTime) |
1 |
124: { |
1 |
125: GraphicsDevice.Clear(Color.CornflowerBlue); |
1 |
126: spriteBatch.Begin(); |
1 |
127: <span style="color: rgb(0, 128, 0);">// TODO: Add your drawing code here</span> |
1 |
128: spriteBatch.DrawString(spriteFont, "<span style="color: rgb(139, 0, 0);">Number of touches: </span>" + touches.Count.ToString(), <span style="color: rgb(0, 0, 255);">new</span> Vector2(10,50), Color.White); |
1 |
129: <span style="color: rgb(0, 0, 255);">foreach</span> (TouchLocation t <span style="color: rgb(0, 0, 255);">in</span> touches) |
1 |
130: { |
1 |
131: spriteBatch.DrawString(spriteFont, t.Id + "<span style="color: rgb(139, 0, 0);"> : </span>" + t.State + "<span style="color: rgb(139, 0, 0);"> : </span>" + t.Position, t.Position + <span style="color: rgb(0, 0, 255);">new</span> Vector2(10,10), Color.White); |
1 |
132: } |
1 |
133: |
1 |
134: spriteBatch.End(); |
1 |
135: <span style="color: rgb(0, 0, 255);">base</span>.Draw(gameTime); |
1 |
136: } |
1 |
137: } |
1 |
138: } |
1 |
139: |
Again simple enough stuff, most of it from the Touch implementation post and you can see the particle manager component added (although because of the spritebatch requirement, I had to move it to the initialise function after the SpriteBatch was initialised). if a touch is recognised on the screen, it launches the “Initialise effect” function.
the initialise effect function (like the previous calls in the particle posts):
- Creates a new instance of the desired effect
- initialises it’s location and start rotation (based on the touch location)
- In this case sets the velocity and acceleration of the effect (I just like to see it move, OK!!!)
- And finally adds the effect to the particle manager
For the final task, you should notice you are still missing two key components. if you compile the project, it will compile, no errors right?, wrong. Run the project and it will fall flat on it’s face. you still need the content you have specified in this project, namely the Spritefont and Explosion image. Just grab these from the Windows Phone 7 or GS 3.1 tutorial projects and paste them in to the POC content project.
Compile again and click on the screen (Touch if you actually have either a phone or a touchscreen laptop you jammy dodgers) and you should see the effect show earlier.
But wait there’s more!!!!
Now when I ran this I wanted to know just how much of an impact doing procedural effects would be to the phone, best way to show this would be to show the frame rate. Now in Silverlight, they have a little programming hook to do this. Does this work for XNA, of course NOT….
So I wrote a handy FPS component that shows you the Updates per second (UPS) and the Draw calls per second (FPS). Here’s the code for it (not much there really, just another drawable component:
1 |
<pre style="margin: 0em; width: 100%; font-family: consolas,"Courier New",courier,monospace; font-size: 12px; background-color: rgb(251, 251, 251);"> 1: <span style="color: rgb(0, 0, 255);">using</span> System; |
1 |
2: <span style="color: rgb(0, 0, 255);">using</span> System.Collections.Generic; |
1 |
3: <span style="color: rgb(0, 0, 255);">using</span> System.Linq; |
1 |
4: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework; |
1 |
5: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Audio; |
1 |
6: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Content; |
1 |
7: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.GamerServices; |
1 |
8: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Graphics; |
1 |
9: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Input; |
1 |
10: <span style="color: rgb(0, 0, 255);">using</span> Microsoft.Xna.Framework.Media; |
1 |
11: |
1 |
12: |
1 |
13: <span style="color: rgb(0, 0, 255);">namespace</span> TouchScreenPOC |
1 |
14: { |
1 |
15: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
16: <span style="color: rgb(128, 128, 128);">/// This is a game component that implements IUpdateable.</span> |
1 |
17: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
18: <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">class</span> FPSCounter : Microsoft.Xna.Framework.DrawableGameComponent |
1 |
19: { |
1 |
20: SpriteFont spriteFont; |
1 |
21: Vector2 FPSCounterLocation = <span style="color: rgb(0, 0, 255);">new</span> Vector2(300, 50); |
1 |
22: SpriteBatch m_spritebatch; |
1 |
23: |
1 |
24: <span style="color: rgb(0, 0, 255);">float</span> FPS; |
1 |
25: <span style="color: rgb(0, 0, 255);">public</span> FPSCounter(Game game, <span style="color: rgb(0, 0, 255);">ref</span> SpriteBatch spriteBatch) |
1 |
26: : <span style="color: rgb(0, 0, 255);">base</span>(game) |
1 |
27: { |
1 |
28: m_spritebatch = spriteBatch; |
1 |
29: <span style="color: rgb(0, 128, 0);">// TODO: Construct any child components here</span> |
1 |
30: } |
1 |
31: |
1 |
32: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
33: <span style="color: rgb(128, 128, 128);">/// Allows the game component to perform any initialization it needs to before starting</span> |
1 |
34: <span style="color: rgb(128, 128, 128);">/// to run. This is where it can query for any required services and load content.</span> |
1 |
35: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
36: <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> Initialize() |
1 |
37: { |
1 |
38: <span style="color: rgb(0, 128, 0);">// TODO: Add your initialization code here</span> |
1 |
39: DrawOrder = 100; |
1 |
40: <span style="color: rgb(0, 0, 255);">base</span>.Initialize(); |
1 |
41: } |
1 |
42: |
1 |
43: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
44: <span style="color: rgb(128, 128, 128);">/// LoadContent will be called once per game and is the place to load</span> |
1 |
45: <span style="color: rgb(128, 128, 128);">/// all of your content.</span> |
1 |
46: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
47: <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> LoadContent() |
1 |
48: { |
1 |
49: <span style="color: rgb(0, 128, 0);">// Create a new SpriteBatch, which can be used to draw textures.</span> |
1 |
50: spriteFont = Game.Content.Load<SpriteFont>("<span style="color: rgb(139, 0, 0);">SpriteFont1</span>"); |
1 |
51: <span style="color: rgb(0, 128, 0);">// TODO: use this.Content to load your game content here</span> |
1 |
52: } |
1 |
53: |
1 |
54: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
55: <span style="color: rgb(128, 128, 128);">/// UnloadContent will be called once per game and is the place to unload</span> |
1 |
56: <span style="color: rgb(128, 128, 128);">/// all content.</span> |
1 |
57: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
58: <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> UnloadContent() |
1 |
59: { |
1 |
60: <span style="color: rgb(0, 128, 0);">// TODO: Unload any non ContentManager content here</span> |
1 |
61: } |
1 |
62: |
1 |
63: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
64: <span style="color: rgb(128, 128, 128);">/// Allows the game component to update itself.</span> |
1 |
65: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
66: <span style="color: rgb(128, 128, 128);">/// <param name="gameTime">Provides a snapshot of timing values.</param></span> |
1 |
67: <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> Update(GameTime gameTime) |
1 |
68: { |
1 |
69: <span style="color: rgb(0, 128, 0);">// TODO: Add your update code here</span> |
1 |
70: <span style="color: rgb(0, 128, 0);">// The time since Update was called last</span> |
1 |
71: <span style="color: rgb(0, 0, 255);">float</span> elapsed = (<span style="color: rgb(0, 0, 255);">float</span>)gameTime.ElapsedGameTime.TotalSeconds; |
1 |
72: |
1 |
73: FPS = 1 / elapsed; |
1 |
74: <span style="color: rgb(0, 0, 255);">base</span>.Update(gameTime); |
1 |
75: } |
1 |
76: |
1 |
77: <span style="color: rgb(128, 128, 128);">/// <summary></span> |
1 |
78: <span style="color: rgb(128, 128, 128);">/// This is called when the game should draw itself.</span> |
1 |
79: <span style="color: rgb(128, 128, 128);">/// </summary></span> |
1 |
80: <span style="color: rgb(128, 128, 128);">/// <param name="gameTime">Provides a snapshot of timing values.</param></span> |
1 |
81: <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> Draw(GameTime gameTime) |
1 |
82: { |
1 |
83: m_spritebatch.Begin(); |
1 |
84: <span style="color: rgb(0, 128, 0);">// TODO: Add your drawing code here</span> |
1 |
85: <span style="color: rgb(0, 128, 0);">//Shows the amount of updates per second (updates per second)</span> |
1 |
86: m_spritebatch.DrawString(spriteFont, "<span style="color: rgb(139, 0, 0);">UPS: </span>" + FPS.ToString(), FPSCounterLocation, Color.White); |
1 |
87: |
1 |
88: |
1 |
89: <span style="color: rgb(0, 0, 255);">float</span> elapsed = (<span style="color: rgb(0, 0, 255);">float</span>)gameTime.ElapsedGameTime.TotalSeconds; |
1 |
90: |
1 |
91: FPS = 1 / elapsed; |
1 |
92: <span style="color: rgb(0, 128, 0);">//Shows the number of draw calls per frame (Frames per second)</span> |
1 |
93: m_spritebatch.DrawString(spriteFont, "<span style="color: rgb(139, 0, 0);">FPS: </span>" + FPS.ToString(), FPSCounterLocation + <span style="color: rgb(0, 0, 255);">new</span> Vector2(0,20), Color.White); |
1 |
94: |
1 |
95: |
1 |
96: m_spritebatch.End(); |
1 |
97: <span style="color: rgb(0, 0, 255);">base</span>.Draw(gameTime); |
1 |
98: } |
1 |
99: } |
1 |
100: } |
And to add it to the game just add the following line in the game initialise function just after the particle manager:
1 |
<pre style="margin: 0em; width: 100%; font-family: consolas,"Courier New",courier,monospace; font-size: 12px; background-color: rgb(251, 251, 251);"> 1: <span style="color: rgb(0, 0, 255);">this</span>.Components.Add(<span style="color: rgb(0, 0, 255);">new</span> FPSCounter(<span style="color: rgb(0, 0, 255);">this</span>, <span style="color: rgb(0, 0, 255);">ref</span> spriteBatch)); |
One line, look at that and now I have an FPS counter (this was demo’ed back in Beta 1 of XNA and most people just went whoooooo), which you can add to any project.
Conclusion
Well enough of all this fun stuff and back to some more serious topics, how about a little sound!.
Smashing Bully, You don’t get anything in this game for two in a bed (So reminded of old 80’s British game shows, name that show!!!)