SpritePixelCollision()

Syntax

Result = SpritePixelCollision(#Sprite1, x1, y1, #Sprite2, x2, y2)
Description
Tests if the two sprites are overlapping. #PB_Sprite_PixelCollision has to be specified at the sprite creation to have this command working.

Parameters

#Sprite1 The first sprite to test.
x1, y1 Coordinates of the first sprite, in pixels.
#Sprite2 The second sprite to test.
x2, y2 Coordinates of the second sprite, in pixels.

Return value

Nonzero if the two sprites are overlapping, zero otherwise.

Remarks

This routine performs a transparent pixel exact collision check, giving a slower but very accurate result. To optimize the comparison you should always remove as many transparent pixels as possible so that the sprite size is fully used by the sprite (i.e. do not have large transparent borders around the actual image of the sprite). Zoomed sprites are also supported.

For a faster collision check based only on rectangular bounds, use SpriteCollision().

Attention, it does not work with sprites that have been rotated or transformed.

See Also

SpriteCollision()

Supported OS

All

<- SpriteOutput() - Sprite Index - SpriteQuality() ->