About Store Forum Documentation Contact



Post Reply 
How to correctly delete an game object?
Author Message
Kevin Offline
Member

Post: #1
How to correctly delete an game object?
Hi,

In my game there are several units which I want to remove as soon as they die.
I want those units to destroy themselves after their health goes under 0. I already tried to return false in the update method but then I get an "pure virtual call" error and really don't know why.

If you need more information please tell. Thanks in advance!
07-09-2012 05:01 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #2
RE: How to correctly delete an game object?
I use removeData(); function from ObjMemx class.
07-09-2012 05:11 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kevin Offline
Member

Post: #3
RE: How to correctly delete an game object?
Thanks, but when I do that I also get an error.

The error raises not immidiately but when the Game.World.update is called the next time.

Quote:Runtime Error!

R6025
- pure virtual function call

I also checked the number of elements in the objmemx and the object was indeed removed, but it seems like the Game.World still has a reference on it...

Any idea?
07-09-2012 09:56 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #4
RE: How to correctly delete an game object?
As I remember I had this error twice. The second time (I don't remeber the first) was when I flown away and object was unloaded from memory and then went back in the area where object was loaded again.

Not sure but I think that this error was caused because you want to do something with this object after it's deleted (in other classes for example). Or maybe there is something wrong in your class codes. Maybe you don't delete everything from object? I really don't remeber what I did to fix this, but maybe try first comment everything from your codes which interfere with objects which you want delete or if it won't help find error inside class.

I've also found this threads on google (community search isn't good smile ):

http://www.esenthel.com/community/showth...p?tid=3568
http://www.esenthel.com/community/showhr...p?tid=2501
(This post was last modified: 07-09-2012 10:24 PM by Harry.)
07-09-2012 10:19 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kevin Offline
Member

Post: #5
RE: How to correctly delete an game object?
Thanks, you were right. I still used a pointer on the object in another class. -.-
07-09-2012 10:39 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: How to correctly delete an game object?
you can also return false in the object update method
07-09-2012 11:02 PM
Find all posts by this user Quote this message in a reply
Post Reply