AGK for Pascal
ContentsIndexHome
PreviousUpNext
TAgkSprite.Distance Method (TAgkSprite, TAgkSprite, TAgkPoint, TAgkPoint)

Calculates the minimum distance separating two sprites.

Syntax
Pascal
class function Distance(const Sprite1: TAgkSprite; const Sprite2: TAgkSprite; out P1: TAgkPoint; out P2: TAgkPoint): Single; overload; static;
Parameters 
Description 
const Sprite1: TAgkSprite 
the sprite to check for distance with Sprite2 
const Sprite2: TAgkSprite 
the sprite to check for distance with Sprite1 
out P1: TAgkPoint 
Returns the closest point on sprite 1 to sprite 2 
out P2: TAgkPoint 
Returns the closest point on sprite 2 to sprite 1 

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. These points are returned in P1 and P2. 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.