C# Rendering the Sample Framework Dialog's

Started by
2 comments, last by k00k 18 years, 8 months ago
Guys here is my setup .. 2 Game States (MainMenu and HostGame) here is my rendering method and how im doing this if (currentState == GameState.MainMenu) { backgroundSprite.Begin(SpriteFlags.AlphaBlend); backgroundSprite.Draw2D(backgroundTexture, System.Drawing.Rectangle.Empty, sampleFramework.ClientRectangle, System.Drawing.Point.Empty, System.Drawing.Color.White); backgroundSprite.End(); gameUI.OnRender(elapsedTime); } if (currentState == GameState.HostGame) { backgroundSprite2.Begin(SpriteFlags.AlphaBlend); backgroundSprite2.Draw2D(backgroundTexture2, System.Drawing.Rectangle.Empty, sampleFramework.ClientRectangle, System.Drawing.Point.Empty, System.Drawing.Color.White); backgroundSprite2.End(); gameUI2.OnRender(elapsedTime); } now that basically just checks the gamestate and renders what is the correct dialog. now my question is this .. if i set the game state to either when im starting the application it renders the menu's no problem .. but if i say start off with teh MainMenu and click the button (HostGame Button) that i have on there which simply does this private void OnHostServer(object sender, EventArgs e) { currentState = GameState.HostGame; } just changes the currentState of the game to HostGame it crashes the application with (System.NullReferenceException: Object Reference not set to an instance of an object) i know its not the Sprite setup because if i remark out the gameUI2.OnRender(elapsedTime) it does change the splash screen without any error's this is completely with the menu's onRender statement. if i have 1 dialog running and i want to change to the other dialog menu .. do i have to Dispose the first dialog somehow or .. what is the deal here .. if anyone can help i will award you with 10 brownie points :[] because im stumped.
Advertisement
Why are you using two seperate sprites? And could you actually tell us what object the null reference is happening on so that we could be more helpful?
Turring Machines are better than C++ any day ^_~
2 Seperate sprites because im changing the background as they navigate thru the menu's :[] regardless i can get it to change the sprites from one menu to the next but .. i cannot get it to draw the new menu inplace of the old menu. thats the main problem here .. here is a url to the error ..

http://www.cadizzy.com/files/pics/error.jpg

Forget it i figured it out .. basically i was creating 2 dialog's for no reason i could create 1 dialog and tell it in my onFrameRender to render the 1 dialog but in the OnResetDevice i could have it add and remove the control's by what state the game/menu's were at. thanks for your help.

This topic is closed to new replies.

Advertisement