At Intermediate Lesson 15...
Re: At Intermediate Lesson 15...
Problem is just declaring MainMenu as a type before the OnEnter function doesnt give any information about members. Therefore, I separated files into .h and .cpp and in PongMenu.cpp I included MainMenu.h. Btw your Menu draw func needs to be virtual and OnEnter function needs to take a Menu*& if I understand correctly. a Menu* will allocate the memory but will not modify the pointer value in game. Good luck.
Computer too slow? Consider running a VM on your toaster.
-
- Posts: 10
- Joined: September 20th, 2014, 6:31 pm
Re: At Intermediate Lesson 15...
Oh ok, yeah I think I figured most of it out now, except for the transition part.
Here is what I was able to get, I tried debugging it but couldn't figure out what's wrong.
Also Idk what you mean by taking a Menu*&
Here is what I was able to get, I tried debugging it but couldn't figure out what's wrong.
Also Idk what you mean by taking a Menu*&
- Attachments
-
- Platformer.zip
- (97.22 KiB) Downloaded 121 times
Re: At Intermediate Lesson 15...
m is not a pointer you cannot call new on an address. I made m a Menu* and made OnEnter take a Menu*& but, you must init the pointer to something. a *& is a reference to a pointer btw.
void Menu::OnEnter(Menu*& state)
{
delete state;
state = new MainMenu();
}
game.h
Menu* m;
game ctor
m = new Menu();
compose frame
m->OnEnter( m );
void Menu::OnEnter(Menu*& state)
{
delete state;
state = new MainMenu();
}
game.h
Menu* m;
game ctor
m = new Menu();
compose frame
m->OnEnter( m );
Computer too slow? Consider running a VM on your toaster.