Class TAdPixelCollisionTester

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TAdPixelCollisionTester = class(TObject)

Description

This class can be used to see whether two user-defined objects collide. TAdPixelCollisionTester manages its own surfaces where the test objects are temporaly drawn at. After sending all test to the class using the "CheckCollision" method, the results can be retrieved using the "GetCollisions" method.

Hierarchy

Overview

Methods

Public constructor Create(AParent: TAdDraw);
Public destructor Destroy; override;
Public procedure CheckCollision(AObj1: TObject; ABoundsRect1: TAdRect; AObj2: TObject; ABoundsRect2: TAdRect; ADrawCallback: TAdCollisionTestDrawProc; ACollisionCallback: TAdCollisionTestCollisionProc);
Public procedure GetCollisions;

Properties

Public property Surface: TAdTextureSurface read FSurface;
Public property AdDraw: TAdDraw read FDraw;

Description

Methods

Public constructor Create(AParent: TAdDraw);

Creates an instance of TAdPixelCollisionTester.

Public destructor Destroy; override;

Destroys the instance of TAdPixelCollisionTester.

Public procedure CheckCollision(AObj1: TObject; ABoundsRect1: TAdRect; AObj2: TObject; ABoundsRect2: TAdRect; ADrawCallback: TAdCollisionTestDrawProc; ACollisionCallback: TAdCollisionTestCollisionProc);

The check collision function performs a collision test between two objects. The only thing you need to have, is a callback function that draws the objects on the surface to a specific position. (ABoundsRect2 specifies the boundsrect of the second object.

Parameters
AObj1
is only a pointer that may contain user data that is in connection with the first collision object.
ABoundsRect1
specifies the boundsrect of the first object.
AObj2
is only a pointer that may contain user data that is in connection with the second collision object.
ADrawCallback
is called when one of the objects should be drawn on a specific surface on a specific position. The pointer given in AObj1 or AObj2 will be sent, to indicate which object should be drawn.
ACollisionCallback
is called when a collision between the two objects takes place. The pointers to the two given objects are sent. This callback function will be called after the "GetCollisions" function is called.
See also
TAdCollisionTestDrawProc
Callback procedure type used by TAdPicelCollisionTester.
TAdCollisionTestCollisionProc
Callback procedure type.
Public procedure GetCollisions;

Analyzes the last collision tests done by CheckCollision. If a collision took place, the "CollisionCallback" method given to CheckCollision is called.

Properties

Public property Surface: TAdTextureSurface read FSurface;

The surface all collision tests take place on. Increase the size of this surface by settings its size via "SetSize" to get more accurate pixel check results.

Public property AdDraw: TAdDraw read FDraw;

The parent AdDraw given in the constructor.

SourceForge.net Logo


Generated by PasDoc 0.11.0 on 2008-12-31 14:32:00