AGK for Pascal
TAgkPhysics.SpriteRayCastGroup Method (Integer, TAgkPoint, TAgkPoint)

Casts a ray through all sprites that have a shape (including physics sprites) and stores the result of any intersection.

class function SpriteRayCastGroup(const Group: Integer; const P1: TAgkPoint; const P2: TAgkPoint): Boolean; overload; static;
const Group: Integer 
The group ID to check for intersection with the ray, can be negative. 
const P1: TAgkPoint 
The start point in world coordinates. 
const P2: TAgkPoint 
The end point in world coordinates. 

True if there was a collision, False if not.

Results of a ray cast can be retrieved using the other ray cast functions and properties such as RayCastNormal. Physics sprites will only use the main shape assigned to the sprite using TAgkSprite.Shape. To check compound shapes use RayCastGroup

If the ray starts inside a shape that shape will not be counted in the results. Sprites must be assigned a shape using one of the sprite shape commands or it will not be included in the collision results. This function is slower than the physics ray casts as it cannot make use of optimized structures that represent where the sprites are in the world relative to the ray. 

This function filters the sprites that are checked so only sprites of a certain group are checked. By default sprites are created in group 0.

Copyright (c) 2012. All rights reserved.