AGK for Pascal
TAgkSprite.Distance Method (TAgkSprite)

Calculates the minimum distance separating this sprites and another sprite.

function Distance(const Other: TAgkSprite): Single; overload;
const Other: TAgkSprite 
the sprite to check for distance with this sprite 

The minimum distance.

If the sprites overlap this will be less than 0. Otherwise it will be the distance between the closest points on each sprite. This calculation takes longer than simply checking if the sprites overlap, if you don' t need the distance spearating the sprites use Collision or CollidesWith

This function is not limited by group or category settings. 

If you have not assigned a shape to either sprite using Shape they will use the default box shape based on the sprite's width and height.

Copyright (c) 2012. All rights reserved.