I have a level creating platformer game that I have been making. In my update loop, if my selected block type is -1, and the mouse is down, then it iterates through a group containing sprites for my game.
In this iteration, I have some code that checks if our mouse is touching that sprite. If it is touching it, then the sprite is destroyed with the destroy(); function. If I only have one sprite in the game, then it works fine, but otherwise it gives me the error "Uncaught TypeError: Cannot read properties of undefined (reading 'body')". I would like it to delete when my mouse touches it. Any help with this would be greatly appreciated.