The Collision Event

The collision event is one of the many events that can be triggered in an instance and may contain code or actions.

The Collision Event
Obviously when making a game, it is very important that you know when two (or more) instances of an object have collided, and for that we have the collision event. This is an event that you place in an object and then specify against which other object you should be checking for collisions.

Now, when you don't have physics turned on, these collisions will be calculated based on the mask of the two objects (the mask is defined within the sprite properties, or can be assigned independently in the object properties) and whether they over-lap or not. Note, that if one or the other instances in the collision does not have a mask assigned (or the sprite mask is set to nothing), even if it is drawing something no collisions will be detected. Also, if the object being collided with is solid, before the collision event code is run the instance is placed back at its previous position before the collision was registered, but only if there is a collision event defined.

If you have physics on, the collision will be based on the type of collision shape that you have defined for the object in its physics properties, as will its reaction to the collision.


Back: Events
Next: The Keyboard Events
© Copyright YoYo Games Ltd. 2018 All Rights Reserved