Jump to content

  • Log In with Google      Sign In   
  • Create Account


Gamestate Manager Tutorial


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 menyo   Members   -  Reputation: 407

Like
0Likes
Like

Posted 16 March 2014 - 01:42 AM

Hi, a year or two ago i was doing a Gamestate Manager Tutorial, I did it two or three times but it was a bit too complicated to fully understand. Now I want to go over it again but i cannot find it anywhere. I believe it was a official tutorial from MSDN or it just looked like it. at least it was based off this sample from MSDN.

 

I can come up with my own menu and state manager now but i am really interested in other methods and it would be nice to see what i did not understand back then.


Current Project: TechnoFlux read all about it on my

DEV BLOG


Sponsor:

#2 idleMartin   Members   -  Reputation: 101

Like
0Likes
Like

Posted 16 March 2014 - 07:04 AM

ah yes, I remember this fondly. I used this as the starting point for most of my xna games. I'll confess I've not used this for over two years but from what I recal it was a very good object oriented sample. The ScreenManager object held a list of GameScreen in a "stack" manner where the one on top was active (unless is was bein transitioned off and out of the list). Menu, gameplay, options screens extended/inherited from the GameScreen class.

Edited by idleMartin, 16 March 2014 - 07:05 AM.


#3 frazchaudhry   Members   -  Reputation: 1140

Like
0Likes
Like

Posted 16 March 2014 - 09:16 AM

Implementing it into your own projects and then making minor modifications to it is the best way to learn what's going on with this sample in my opinion.


Edited by frazchaudhry, 16 March 2014 - 10:28 AM.


#4 Aurioch   Crossbones+   -  Reputation: 1295

Like
0Likes
Like

Posted 16 March 2014 - 02:16 PM

Other method you can use - and which I'm right now experimenting in Orbstinate, with success atm, is to use XNA's GameComponent and DrawableGameComponent classes.

 

Basically, you have to create a new class which will inherit either one of those two (difference is that DrawableGameComponent has public virtual void Draw(GameTime gametime) method in addition to Initialize(), LoadContent(), UnloadContent() and Update(GameTime) methods) and write all the relevant stuff inside. Then, you register the component when you need it, for example:

public class Game1 : Microsoft.XNA.Framework.Game
{
    // snip

        MainMenu main = new MainMenu(this);
        Components.Add(main);

    // snip
}

Game itself will take care of running all relevant methods of each component registered onto Game.Components list when required. So, it boils down to adding components to or removing components from the Components list, which isn't so much different from the Gamestate Manager example Microsoft provided (and which was my starting point as well).

For example, in my game, I'm usually running Main Menu, Options Menu or Game part itself as one component, with Sound Manager being separate component which runs whole time.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS