sprite_delete

Deletes the sprite from memory, freeing the memory used.

Syntax:

sprite_delete(index);


Argument Description
index The index of the sprite to be deleted.


Returns: N/A


Description

This function will delete a sprite from the game, freeing any memory that was reserved for it. This is a permanent removal, and if the asset that you delete was included as part of the game's resources, not even restarting the game (unless you close the application first) will recover it. This is a very important function for those moments when you need to create and change sprites from external resources and should always be used to remove those assets that are no longer needed by a game, or to clear an indexed asset from a variable before re-assigning another asset to that variable.


Example:

var spr = sprite_create_from_surface(application_surface, 0, 0, 32, 32, false, false, 16, 16);
sprite_merge(spr_Player, spr);
sprite_delete(spr);

The above code creates a local variable and then stores the index of the sprite created from the application surface. This sprite is then merged with the asset indexed in the variable "spr_Player" before being removed from memory again.


Back: Sprites
Next: sprite_set_alpha_from_sprite
© Copyright YoYo Games Ltd. 2018 All Rights Reserved