How To

How to trigger a SUB when jumping over something


nebyoolae 2023-09-16 20:08

If I have SPRITE 1, and it needs to trigger a SUB when it jumps over SPRITE 2, how would I code that?

Right now, the jump code knows if SPRITE 1 is HITting SPRITE 2, so it invalidates the jump success, but that means it triggers if I jump at any time, not specifically OVER SPRITE 2.

Nebyooskate.nx | Open in app
2023-09-16 20:08

McPepic 2023-09-16 20:22

You could use a dummy sprite. When the player jumps, you place a sprite over the enemy. If this sprite hits the player, then the player successfully jumped over. You then disable the sprite afterward.

nebyoolae 2023-09-16 22:05

Wow! That’s genius. Implementing now.

was8bit 2023-09-17 13:02

The power of sprites ;)

Timo 2023-09-17 13:07

Another way would be just comparing the X and Y coordinates of the sprites. But using hidden sprite collisions is fine, too.

was8bit 2023-09-18 12:19

You might find this interesting :)

Log in to reply.