So I have been using new a lot for my game because I am declaring pointers to some of my game objects and then initializing them later like so:
Character* Guy;
Guy = new Character(SpawnPosX,SpawnPosY);
Now my question is do I call delete after the game is over like lets say the player quits out to the main menu is that when I should call delete?
Also I have a lot of enemies that I do that with should I call delete whenever they die or just when the level is done?
One last thing, if I were to call delete based off if the enemy is alive would I have to make a bool to make sure that it only tries to delete the memory once for example:
if(Enemy->bIsDead)
{
delete Enemy;
}
If I ran that and then the next time it looped through my game loop it would come to this line and try and delete it again. I would really only use this if you are supposed to call delete right when an enemy dies.
Anyway I really appreciate any help that can be given. =)