Hi, I'm new here, so sorry if this is a stupid question or something.
In my game, I have a Stage Manager class, which basically controls which "stage" the user is in right now. (EG: The menu, or the game)
Each stage is a class derived from a stage called stg_basic.
The stage is changed by using StageManager::changeStage(stg_basic* newStage)
Here is a simplified version of changeStage:
1 2 3 4 5 6 7
|
bool StageManager::changeStage(stg_basic* newStage)
{
//Create the new stage
stage = newStage;
stage->stage_start();
return true;
}
|
I've tried multiple things to try and pass the new stage's class through the newStage argument, but nothing seems to work right.
However, with the above code I was able to get this to work:
1 2
|
stg_menu newmenu;
stageman.changeStage(&newmenu);
|
It's messy, but it works. However, I don't like having to create the stage using a variable then pass the variable. I've tried multiple things and can't seem to get something that works. (Some of it compilers, but I just get an exception.)
So basically:
Does anyone know how I can create a class, then pass it to my changeStage function without an extra variable?
OR
Does anyone know how I can specify a class to be created using changeStage?
Thank you for your time, sorry again if this should be obvious.
~DtD