hoffhoff
14-12-2008 16:35:31
Hello,
I am creating a shooting game, and then I want my "bullet" object to be destroyed after 5 seconds since it was shot.
My "Bullet" class agregates an OgreNewt::Body* (mpBody), an Ogre::Entity* (mpEntity) and an Ogre::SceneNode* (mpSceneNode) basically.
In the destructor, I am doing this:
I am calling the "delete bullet;" in the "frameStarted" event of my Event class, which is derivated from "Ogre::FrameListener".
My code works fine in the Debug mode, but crashes when compiled in the Release mode.
Is there something wrong with the steps I am doing? I mean... is it fine to delete the objects in the "frameStarted" event?
Also, is there something I should do before trying to delete a body?
Thanks!
I am creating a shooting game, and then I want my "bullet" object to be destroyed after 5 seconds since it was shot.
My "Bullet" class agregates an OgreNewt::Body* (mpBody), an Ogre::Entity* (mpEntity) and an Ogre::SceneNode* (mpSceneNode) basically.
In the destructor, I am doing this:
if (mpBody)
{
delete mpBody;
mpBody = NULL;
}
if (mpEntity)
{
delete mpEntity;
mpEntity = NULL;
}
if (mpSceneNode)
{
delete mpSceneNode;
mpSceneNode = NULL;
}
I am calling the "delete bullet;" in the "frameStarted" event of my Event class, which is derivated from "Ogre::FrameListener".
My code works fine in the Debug mode, but crashes when compiled in the Release mode.
Is there something wrong with the steps I am doing? I mean... is it fine to delete the objects in the "frameStarted" event?
Also, is there something I should do before trying to delete a body?
Thanks!