Hi,
I was just wondering why since we started moving our code into separate classes, we stopped unloading the textures at the end of the program? It seems that we are now only unloading the map texture at the end of the main function.
My c++ knowledge is still quite basic but I know that the compiler does call automatically the destructor for each class at the end of a program if we don’t define one (like we do with the constructor). But in context with UnloadTexture(), my idea was to make us of it.
For example, I would declare the destructor in the BaseCharacter.h file and then define it in the source file. Inside the destructor’s body I would call the UnloadTexture function for each texture, so when the program ends and the destructor gets called it would take care of unloading the textures from memory as well.
BaseCharacter::~BaseCharacter()
{
UnloadTexture(texture);
UnloadTexture(tex_idle);
UnloadTexture(tex_run);
}
Same procedure with the sword in the Character class and the props in the Prop Class.
Now my question is: Is this a correct way to do it? Or am I missing something here?
Instinctively, I think this is still a necessary task to complete at the end of the program. If not, I would like to understand why.
Thanks!
Nicole