dhp
03-03-2007 20:03:31
I've been working on a fighting game and have encountered a major problem when dealing with OgreNewt. Basically, I have 2 game states: MenuState and MultiPlayerState. The MultiPlayerState is where the actual fighting takes place.
In my code I have...
and elsewhere I have...
and finally...
For testing purposes, I start my game in the MultiPlayerState. When I press F12 to change to MenuState, that's when the game crashes. I've verified that MultiPlayerState::exit() is called and the game gets into and to the end of MenuState::enter(). From what I know, it should then go to frameStarted? But it never reaches that point in MenuState. Here are images of the crash I get...
(this pops up first)
(followed by this)
Anyway, the reason I believe I'm doing something wrong with OgreNewt is because when I comment out all OgreNewt related stuff, it switches states fine! No errors at all.
Any help will be greatly appreciated. Thanks!
In my code I have...
void MultiPlayerState::enter()
{
.
..
...
// Initialize the physics world
mWorld = new OgreNewt::World();
mWorld->setWorldSize(Ogre::Vector3(-500, -500, -500), Ogre::Vector3(500, 500, 500));
mNewtonListener = new COgreNewt_FL(mSceneMgr, mWorld, 200);
mRoot->addFrameListener(mNewtonListener);
...
..
.
}
and elsewhere I have...
void MultiPlayerState::exit()
{
mSceneMgr->clearScene();
mSceneMgr->destroyAllCameras();
mRoot->removeFrameListener(mNewtonListener);
mRoot->getAutoCreatedWindow()->removeAllViewports();
mRoot->destroySceneManager(mSceneMgr);
if(mNewtonListener)
delete mNewtonListener;
if(mWorld)
delete mWorld;
}
and finally...
bool MultiPlayerState::frameEnded(const FrameEvent& evt)
{
.
..
...
if(keyDown(KC_F12)) // keyDown is macro
{
changeState(MenuState::getInstance());
}
return true;
}
For testing purposes, I start my game in the MultiPlayerState. When I press F12 to change to MenuState, that's when the game crashes. I've verified that MultiPlayerState::exit() is called and the game gets into and to the end of MenuState::enter(). From what I know, it should then go to frameStarted? But it never reaches that point in MenuState. Here are images of the crash I get...
(this pops up first)
(followed by this)
Anyway, the reason I believe I'm doing something wrong with OgreNewt is because when I comment out all OgreNewt related stuff, it switches states fine! No errors at all.
Any help will be greatly appreciated. Thanks!