Dynamic errors

Started by Vincent, Tue 10/06/2014 18:18:37

Previous topic - Next topic

Vincent

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

Cogliostro

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

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


- Cogliostro
"First things first, but not necessarily in that order." - Dr. Who

Vincent

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.

Vincent

This is what i have so far :

Code: ags

//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();
}

SMF spam blocked by CleanTalk