Jump to content
  • Advertisement
Sign in to follow this  
k00k

C# Rendering the Sample Framework Dialog's

This topic is 4834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!