AGK for Pascal
TAgkSprite.Distance Method (TAgkSprite, TAgkSprite)

Calculates the minimum distance separating two sprites.

class function Distance(const Sprite1: TAgkSprite; const Sprite2: TAgkSprite): Single; overload; static;
const Sprite1: TAgkSprite 
the sprite to check for distance with Sprite2 
const Sprite2: TAgkSprite 
the sprite to check for distance with Sprite1 

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.