At Intermediate Lesson 15...

The Partridge Family were neither partridges nor a family. Discuss.
cameron
Posts: 794
Joined: June 26th, 2012, 5:38 pm
Location: USA

Re: At Intermediate Lesson 15...

Post by cameron » November 2nd, 2014, 5:08 pm

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.

tribalzero
Posts: 10
Joined: September 20th, 2014, 6:31 pm

Re: At Intermediate Lesson 15...

Post by tribalzero » November 4th, 2014, 9:03 pm

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*&
Attachments
Platformer.zip
(97.22 KiB) Downloaded 121 times

cameron
Posts: 794
Joined: June 26th, 2012, 5:38 pm
Location: USA

Re: At Intermediate Lesson 15...

Post by cameron » November 4th, 2014, 11:55 pm

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 );
Computer too slow? Consider running a VM on your toaster.

Post Reply