Is there a way to only destroy the oldest sprite in a group of sprites of the same name?

here’s the deal. i want to know how to destroy the sprite of a specific name that’s been onscreen the longest, instead of the latest one.

something like:

[destroy oldest sprite (sprite variable name)]

as opposed to…

[destroy (variable name)]

if this is an option, i would appreciate knowing where i can find it, if not, it would be great if someone could make an extension for it. thank you, and stay creative!

3 Likes

Idea to implement:

  1. On sprite creation, use sprite data to assign the current game ms.
  2. To destroy the oldest sprite just iterate over all of them or the type you want and just destroy the sprite data with the smallest game time, as that would be the oldest
4 Likes

u could use a timer and put it just after the “make my sprite” block.

1 Like

Try accessing the first element of the get all sprites of kind block. I believe they are placed there in order of creation. Once you define a sprite (eg. mySprite), that sprite is now assigned to the variable. When you assign it again, the variable is now the new sprite, and the old one persists in the game, but is no longer assigned.

Here’s an example.

(press A to destroy a sprite)

I hope this helps, if you have any more questions, please ask!

2 Likes

Try adding the sprites to an array as they’re created, then destroy the sprite with an index of 0.

1 Like


This should work. :slight_smile:

2 Likes