How do I fix/optimize this code to filter a list?

I have a list of all image sprites but I need it to only have sprites with a certain name is it possible to do without manually added them or manually removing them all when screen initialized. (Idk if the screenshot worked but if you can see it could you also tell me why it doesn't work also in the screenshot it isn't attached to anything but it was when I tested the app.) Running latest iOS on iPhone 13

I did this

Show what exactly the spriteList contains, because if there are sprites - components, it won't work.

Here is all the code that I currently have

This won't work because the Spriteist doesn't contain their names. Display this list in the label and you will see what is there.

1 Like

So what should I do to fix this problem?

I think you have to create the list manually.

dang ok

You can create one large list of pairs. Sprite, name of the sprite. Then you will be able to use such a list for various operations on sprites.

here is an example to spawn bullets:

bullets.aia (8.0 KB)

We need 2 list, one for available bullets, one for flying bullets.

when spawn a bullet, pick and remove a bullet from available list, add it to flying list.
When bullet hit target, pick and remove this bullet from flyling list, add it to available list.

In this example we use Clock.Timer to move the bullet. You can set its speed/interval/heading without using a clock.

Thanks for the help but this won't work with my game. I think ill just do it manually.