I’m trying to create a main menu for my game but when I try to run the compiled code, it gives me:
Unhandled exception at 0x77bb15ee in TicTacToeCube.exe: 0xC0000005: Access violation reading location 0x00000064.
Here is the code:
void MainMenu::ShowMenu() {
aspect2d = win_ptr->get_aspect_2d();
PT(Texture) Button_ReadyTex = TexturePool::load_texture("Button_Ready.png");
PT(Texture) Button_RolloverTex = TexturePool::load_texture("Button_Rollover.png");
PT(Texture) Button_PressedTex = TexturePool::load_texture("Button_Pressed.png");
PT(Texture) Button_InactiveTex = TexturePool::load_texture("Button_Inactive.png");
// NewGameBtn
NewGameBtn = new PGButton("NewGame");
NewGameBtn->setup("New Game");
NewGameBtn_Style = NewGameBtn->get_frame_style(0);
NewGameBtn_Style.set_type(PGFrameStyle::T_flat);
NewGameBtn_Style.set_texture(Button_ReadyTex);
NewGameBtn->set_frame_style(0, NewGameBtn_Style);
NewGameBtn_Style.set_texture(Button_RolloverTex);
NewGameBtn->set_frame_style(1, NewGameBtn_Style);
NewGameBtn_Style.set_texture(Button_PressedTex);
NewGameBtn->set_frame_style(2, NewGameBtn_Style);
NewGameBtn_Style.set_texture(Button_InactiveTex);
NewGameBtn->set_frame_style(3, NewGameBtn_Style);
NewGameBtn_Np = aspect2d.attach_new_node(NewGameBtn);
NewGameBtn_Np.set_scale(1.0);
}
It breaks at this line:
NewGameBtn = new PGButton("NewGame");
Btw, here are the definitions for everything that is used in the code above:
NodePath aspect2d;
WindowFramework *win_ptr;
PT(PGButton) NewGameBtn;
NodePath NewGameBtn_Np;
PGFrameStyle NewGameBtn_Style;
I’m using VS 2008 Pro x64 on Win7 Pro x64 with Panda3D 1.7.2
Thanks for any help you can provide.