Event: Collide(target1, target2)

Related Events: apart
Related Actions: letcollide
See also: FKiSS, Events, Actions

collide(target1, target2)

First defined in: FKiSS2
The collide event makes a comparison based on the individual pixels of the two targets. If any pixel for target1 overlaps a a pixel for target2 and no pixels previously overlapped, this event will occur.
This event may be triggered by the user picking up an object and dropping it somewhere else or by FKiSS movement.
Since pixel-by-pixel comparison is more task-intensive, only use this event to react to collision-detection when pixel-collision detection is necessary.
Only one collide event should exist for any target1-target2 pair.

target1

In FKiSS2 to FKiSS3, target1 must be a cel.
In FKiSS4, target1 may be an object number, cel, or group.

target2

In FKiSS2 to FKiSS3, target2 must be a cel.
In FKiSS4, target2 may be an object number, cel, or group.

Example:

;@ collide("this.cel", "that.cel") ; When any pixel in "this.cel" overlaps any pixel in "that.cel"...
;@   sound("bell.wav")             ; Play a sound.