on Hit Wall
Run some code when a sprite contacts a wall.
We can detect when a moving sprite contacts a wall in the scene. You can then run some code if your sprite touches a location that is set as a wall. You choose the sprite kind to check for wall collisions.
When a wall hit is detected the sprite of the kind you asked for is given to you in the sprite parameter of handler.
A a sprite hitting a wall is dectected when the outside edges of their images make contact. If a sprite has it’s ghost
flag set, any contact with the wall is ignored.
Parameters
- kind: the type of sprite to check for a wall hit.
- handler: the code to run when the sprite makes contact.
- sprite: the sprite that hit the wall tile.
Example
Build a brick wall of tiles in the scene. Use the A to send a Ghost
sprite toward the wall and watch it stop. When button B is pressed, switch the value of the ghost
flag and see if the ghost sprite hits the wall or goes through.