Sprite overlap with lava dies

I have a student who’s sprite loses all their lives when it contact lava, instead of just 1 life. When I swap out the sprite for a smaller one, it doesn’t have the same issue. I’m pretty sure it’s got to do with the size of this sprite, but I can’t figure out how to get the sprite to respawn and only lose 1 life.



it probably is the size. I think the size of the sprite makes it contact multiple lava tiles.


This is what is happening. There might be a cleaner way to do this, but you could remove the life in an onGameUpdate block instead like so:

1 Like

Thanks so much! This looks like a good place to start. I appreciate the idea, and I’ll go play with it.

Never mind, I found it (maybe). The player is actually never given any lives, so its basically only declared that they should when they lose one. At the beginning of the program, add
Set life to (3)
(3 is the number of lives)

You can make it so that when the player touches the lava, they instantly get teleported to the respawn location. Then, the code only takes away one live.
You could also make a variable, “In lava”. When the player is in the lava, then “In lava” is set to true or 1. The player only gets dealt damage if “In lava” is false or 0.

There is a problem with this. If the player overlaps more than 1 lava tile at once, then they will still lose >1 lives.