AGK for Pascal
ContentsIndexHome
PreviousUpNext
TAgkPhysics.SpriteRayCast Method (Single, Single, Single, Single)

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

Syntax
Pascal
class function SpriteRayCast(const X1: Single; const Y1: Single; const X2: Single; const Y2: Single): Boolean; overload; static;
Parameters 
Description 
const X1: Single 
The X coordinate of the start point in world coordinates. 
const Y1: Single 
The Y coordinate of the start point in world coordinates. 
const X2: Single 
The X coordinate of the end point in world coordinates. 
const Y2: Single 
The Y coordinate of 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 RayCast

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 only ray casts as it cannot make use of optimized structures that represent where the sprites are in the world relative to the ray.

Copyright (c) 2012. All rights reserved.