LoginLogin
Might make SBS readonly: thread

SPHITSP

Root / Documentation / [.]

Created:
Checks for collisions between two selected sprites.

Syntax

hit = SPHITSP(first, second)
InputDescription
firstID of first sprite to check collision between
secondID of second sprite to check collision between
OutputDescription
hitIndicates if there was a collision detected
SPHITSP checks for collisions between the two sprites with ids first and second. When a collision occurs, the value returned from SPHITSP will be TRUE, and this function also sets the system variables SPHITX, SPHITY, and SPHITT. If no collision occurs, SPHITSP instead returns FALSE. SPHITSP does not cause SPHITNO to be set, unlike SPHIT, The hitboxes used for sprite collision detection can be modified by SPCOL and SPCOLVEC.

Examples

' Create two sprites and check for their collision.
SPSET 0,64,3,0,0,0 ' Create boy sprite
SPSET 1,96,2,0,0,0 ' Create witch sprite
' Check for collision between the boy and the witch
HIT=SPHITSP(0,1)
PRINT HIT
' Prints 1 (TRUE)
' Create two sprites and check for their collision.
SPSET 0,64,3,0,0,0 ' Create boy sprite
SPSET 1,96,2,0,0,0 ' Create witch sprite
SPOFS 1,64,0 ' Move witch over 64 pixels
' Check for collision between the boy and the witch
HIT=SPHITSP(0,1)
PRINT HIT
' Prints 0 (FALSE)

Notes

All arguments are rounded down.

Errors

ActionError
Less than two arguments are passedSyntax error
More than three arguments are passedMissing operand
first is greater than 99 or less than zeroOut of range
second is greater than 99 or less than zeroOut of range
The sprite first does not existIllegal function call
The sprite second does not existIllegal function call
A string argument is passedType Mismatch

See Also

No posts yet (will you be the first?)