Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Vincent on Tue 10/06/2014 18:18:37

Title: Dynamic errors
Post by: Vincent on Tue 10/06/2014 18:18:37
Good evening to all Agser!
I received this strange message after building the game

(in room 1): Dynamic sprite 97 was never deleted

I'm pretty sure I've called the delete command to free its memory after use it
But can't understand how to solve this warning
Title: Re: Dynamic errors
Post by: Cogliostro on Tue 10/06/2014 19:11:37
You're a little short on information, and that makes anyone who tries to help do a lot of guesswork.  Make it easier on yourself by posting the code that generates the error.  However, in this particular case, it really should be just what it says.  You created a dynamic sprite in your first room and did not delete it.

In anyroom I use dynamic sprites, I take case of it by deleting them when the player leaves the room.

Code (ags) Select

function room_Leave()
{   
   dynButton.Delete();
}


- Cogliostro
Title: Re: Dynamic errors
Post by: Vincent on Tue 10/06/2014 21:49:49
Hello Cogliostro.
Thanks for the reply.

Navigating, after a while, into the forum boards i found this topic :

http://www.adventuregamestudio.co.uk/forums/index.php?topic=46725.msg636445161#msg636445161

How you said before, the possible solution could be
To delete them when player quits the room or just adding on_event function.
But what about if player push the X button on the corner of the window or (in my case) player can quit the game by pushing a gui button ?

Quote
« Last Edit: 04 Feb 2013, 07:49 by Crimson Wizard »

This is a quite usual thing when you use global Dynamic Sprites in AGS. Unfortunately, AGS does not have "On Quit" event that will let you to delete your stuff in time.
AGS deletes all created Dynamic sprites anyway. But it still posts those annoying warnings.
Possible solution is to delete them when player quits using available in-game option. But that won't work in case user exits by hitting Alt+X or closing the window by X button in the corner.
Title: Re: Dynamic errors
Post by: Vincent on Tue 10/06/2014 22:48:53
This is what i have so far :

Code (ags) Select

//header
struct Carciofi
{
  import function Crea();
};

import Carciofi Patate;

//global
Carciofi Patate;
export Patate;

struct Punti
{
  float x;
  float y;
  float xx;
  float yy;
};

#define SEGMENTO 32

Punti something[33];
float Paperino, Pippo, Pluto, Topolino;
DynamicSprite *banane;

//here there's other functions that take care of Carciofi

function Carciofi::Crea()
{
  banane = DynamicSprite.CreateFromBackground();

  float ss = IntToFloat(SEGMENTO);
  float destra = (Pluto - Paperino)/ss;
  float sinistra = (Topolino - Pippo)/ss;
  float xxx = Paperino;
  float yyy = Pippo;
  int i = 0;
  while (i <= SEGMENTO)
  {
    something[i].x = xxx;
    something[i].y = yyy;
    something[i].xx = xxx;
    something[i].yy = yyy;
    xxx = xxx + destra;
    yyy = yyy + sinistra;
    i++;
  }
  int v = 0;
  while (v < 300)
  {
    //Update Carciofi
    v++;
  }
  banane.Delete();
}