Springare
15-01-2008 18:24:05
hi me again ^^,
I got another problem whit my callbacks... been trying to figure it out all day. in my callback I check what my shot hits and then do some things then after I want to delete the shot from the memory. But how do I delete it? I tried to call "delete" on the actor I get in the callback but it crashs and tried disable but then it just becomes invisible and won't update but it still takes up memory so after a while I get like 2 fps '^^
here's my callback class
is it possible to delete the shot in the callback??
I got another problem whit my callbacks... been trying to figure it out all day. in my callback I check what my shot hits and then do some things then after I want to delete the shot from the memory. But how do I delete it? I tried to call "delete" on the actor I get in the callback but it crashs and tried disable but then it just becomes invisible and won't update but it still takes up memory so after a while I get like 2 fps '^^
here's my callback class
class tankShotCallback : public GroupCallback::InheritedCallback
{
public :
tankShotCallback()
{
}
void onStartTouch(Actor *a, Actor *b)
{
Body * ad = static_cast<Body*>(a);
String temp = b->getName();
if(temp == "Level01.mesh") // if the shot hits the ground
{
/////
// Removes/Deletes the shot
//////
//ad->_destroyActor();
//delete ad;
//delete a;
//a->_destroyActor();
ad->disable();
}
else if(temp == "M60Body.mesh") // if the shot hit's player 1 (red tank)
{
/////////////////
//Tank looses health
/////////////////
/////
// Removes/Deletes the shot
//////
//ad->_destroyActor();
//delete ad;
//delete a;
//a->_destroyActor();
ad->disable();
}
}
void onEndTouch(Actor *a, Actor *b)
{
}
void onTouch(Actor *a, Actor *b)
{
}
};
is it possible to delete the shot in the callback??