I am trying to get the falling food to destroy when touched by the player, but it only affects the most recently created sprite. I need some help. I have already tried following another forum post, but it didnt work.
Hello! Welcome to the forum!
It looks like when the sprite overlaps, for example, a hamburger, you delete that sprite. The problem is, the “set [hamburger] to sprite…” block only holds the most recent hamburger created, so if another hamburger gets created, the old hamburger sprite is not associated with the “hamburger” variable anymore!
Instead, it is only part of the array of “eat” sprites.
What you need to do is change your code so that the element “value” of the “array of sprites of kind (eat)” is getting deleted, like this:
You can drag and drop that “value” block out of the For loop and into those spots.
Something that might make your code even simpler would be to use the built in On Sprite Overlap Othersprite block:
That one is in the Sprites tab and is much easier to use.
Hope this helps!
Also, If you decide to use the “on sprite of kind ___ overlaps other sprite of kind___”, make sure to drag the “other sprite” option onto the Sprite Black that’s inside of it, which in this case is
“destroy other sprite”