About Store Forum Documentation Contact



Post Reply 
States in class
Author Message
joshka Offline
Member

Post: #1
States in class
Hi:

I want create states in class, eg: intro, menu, game.... but i can't create de Object State in my class.

I have the following class:

Code:
class Intro{
public:
          Bool init();
      Bool update();
      void draw();
      void shutdown();
      State StateIntro;

   protected:
      Intro(){
        StateIntro(&Intro::update, &Intro::draw, &Intro::init, &Intro::shutdown);
      }
      ~Intro(){
      }
      Intro(const Intro & );
      Intro &operator= (const Intro & );
};

but this example doesn't compile, how can i create the object State?

Thank you!

PD: Im former of DaveTs dev team
(This post was last modified: 11-06-2011 11:25 PM by joshka.)
11-06-2011 11:17 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #2
RE: States in class
Take a look at the Simple Project in the Projects tutorials folder for an example of using states.
11-07-2011 12:45 AM
Find all posts by this user Quote this message in a reply
joshka Offline
Member

Post: #3
RE: States in class
i looked the SimpleProject tutorial but i want handle the states through classes (singleton), then i need create the State object in my class, but i can't create it.

Sorry i'm beginner in c++
11-07-2011 08:23 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #4
RE: States in class
If you are weak at c++, then I would suggest googling c++ singletons and find a simple exmaple that you can build off.
11-07-2011 10:45 AM
Find all posts by this user Quote this message in a reply
joshka Offline
Member

Post: #5
RE: States in class
i have the singleton class, but i have omitted code. how can i initialize the state object in my class??
11-07-2011 12:34 PM
Find all posts by this user Quote this message in a reply
Post Reply