Class TPHXSpriteEngine

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TPHXSpriteEngine = class(TObject)

Description

Sort sprites by the layer Call the collide function from the update Cull sprites that are outside the viewport Limit scrolling so it doesnt go outside the engine bounds Sprite engine

Hierarchy

  • TObject
  • TPHXSpriteEngine

Overview

Fields

Protected FInitialized: Boolean;

Methods

Public constructor Create(ADevice: TPHXDevice); overload; virtual;
Public constructor Create(ADevice: TPHXDevice; const AWidth: Integer; AHeight: Integer); overload; virtual;
Public destructor Destroy; override;
Public procedure Initialize; virtual;
Public procedure Update(const DeltaTime: Double); virtual;
Public procedure Collide; overload;
Public procedure Render;
Public procedure RenderBounds(Canvas: TPHXCanvas; const Color: TColor4f);
Public procedure RenderShapes(Canvas: TPHXCanvas; const Color: TColor4f);
Public procedure RenderColliders(Canvas: TPHXCanvas; const Color: TColor4f);
Public procedure RenderNames(Font: TPHXFont; const Color: TColor4f);
Public procedure Collide(Sprite: TPHXSprite; Collisions: TPHXSpriteCollisionList); overload;
Public procedure Collide(Sprite: TPHXSprite; Collisions: TPHXSpriteCollisionList; const Filter: TPHXSpriteCollisionFilter); overload;
Public procedure Collide(Sprite: TPHXSprite; Collisions: TPHXSpriteCollisionList; const Group: TPHXSpriteCollisionGroup); overload;
Public function SpriteAt(const X,Y: Single): TPHXSprite; overload;
Public function SpriteAt(const Position: TVector2f): TPHXSprite; overload;
Public function ScreenToWorld(const X, Y: Single): TVector2f; overload;
Public function ScreenToWorld(const Position: TVector2f): TVector2f; overload;
Public function ScreenToWorld(const Position: TVector2i): TVector2f; overload;
Public function WorldToScreen(const X, Y: Single): TVector2f; overload;
Public function WorldToScreen(const Position: TVector2f): TVector2f; overload;
Public function WorldToScreen(const Position: TVector2i): TVector2f; overload;
Public function CountSpritesByKind(const Kind: TPHXSpriteClass): Integer; overload;
Public procedure RemoveDead;

Properties

Public property Root: TPHXSprite read FRoot;
Public property Collider: TPHXSpriteCollider read FCollider write SetCollider;
Public property Factory: TPHXSpriteFactory read FFactory;
Public property Camera: TPHXSpriteCamera read FCamera;
Public property Options: TPHXSpriteOptions read FOptions write SetOptions;
Public property Sprites: TList read FSprites;
Public property Dead: TList read FDead;
Public property Count: Integer read GetCount;
Public property Width: Integer read FWidth write FWidth;
Public property Height: Integer read FHeight write FHeight;
Public property Bounds: TRectf read GetBounds;
Public property Images: TPHXImageList read FImages write FImages;
Public property Animations: TPHXAnimationList read FAnimations write FAnimations;
Public property Shapes: TPHXShapeList read FShapes write FShapes;

Description

Fields

Protected FInitialized: Boolean;

Flag telling if the sprite engine has been initialized

Methods

Public constructor Create(ADevice: TPHXDevice); overload; virtual;

Create a new sprite engine

Public constructor Create(ADevice: TPHXDevice; const AWidth: Integer; AHeight: Integer); overload; virtual;

Create a new sprite engine

Public destructor Destroy; override;

Free this sprite engine

Public procedure Initialize; virtual;

Initialize the engine

Public procedure Update(const DeltaTime: Double); virtual;

Updates all the sprites, the collider and removes all sprites marked as dead

Parameters
DeltaTime
The elapsed time since the last update
Public procedure Collide; overload;

Collide all sprites

Public procedure Render;

Draw all sprites

Public procedure RenderBounds(Canvas: TPHXCanvas; const Color: TColor4f);

Draw the bounding boxes for all sprites

Public procedure RenderShapes(Canvas: TPHXCanvas; const Color: TColor4f);

Draw the shapes for all sprites

Public procedure RenderColliders(Canvas: TPHXCanvas; const Color: TColor4f);

Render all sprites that are marked as colliders

Public procedure RenderNames(Font: TPHXFont; const Color: TColor4f);

Draw the shapes boxes for all sprites

Public procedure Collide(Sprite: TPHXSprite; Collisions: TPHXSpriteCollisionList); overload;

Collide a sprite against the sprites in the engine

Public procedure Collide(Sprite: TPHXSprite; Collisions: TPHXSpriteCollisionList; const Filter: TPHXSpriteCollisionFilter); overload;

Collide a sprite against the sprites in the engine

Public procedure Collide(Sprite: TPHXSprite; Collisions: TPHXSpriteCollisionList; const Group: TPHXSpriteCollisionGroup); overload;

Collide a sprite against the sprites in the engine

Public function SpriteAt(const X,Y: Single): TPHXSprite; overload;

Returns the sprite at a positions

Public function SpriteAt(const Position: TVector2f): TPHXSprite; overload;

Returns the sprite at a positions

Public function ScreenToWorld(const X, Y: Single): TVector2f; overload;

Converts a screen position to a world position

Public function ScreenToWorld(const Position: TVector2f): TVector2f; overload;

Converts a screen position to a world position

Public function ScreenToWorld(const Position: TVector2i): TVector2f; overload;

Converts a screen position to a world position

Public function WorldToScreen(const X, Y: Single): TVector2f; overload;

Converts a world position to a screen position

Public function WorldToScreen(const Position: TVector2f): TVector2f; overload;

Converts a world position to a screen position

Public function WorldToScreen(const Position: TVector2i): TVector2f; overload;

Converts a world position to a screen position

Public function CountSpritesByKind(const Kind: TPHXSpriteClass): Integer; overload;

Count the number of sprites by kind

Public procedure RemoveDead;

Delete and destroy all dead sprites

Properties

Public property Root: TPHXSprite read FRoot;

The root sprite

Public property Collider: TPHXSpriteCollider read FCollider write SetCollider;

The sprite collider

Public property Factory: TPHXSpriteFactory read FFactory;

The sprite factory

Public property Camera: TPHXSpriteCamera read FCamera;

The sprite camera

Public property Options: TPHXSpriteOptions read FOptions write SetOptions;

Options for the sprite list

Public property Sprites: TList read FSprites;

List of all sprites

Public property Dead: TList read FDead;

List of dead sprites, will be cleared by RemoveDead

Public property Count: Integer read GetCount;

Returns the number of sprites in the list

Public property Width: Integer read FWidth write FWidth;

Width of the world

Public property Height: Integer read FHeight write FHeight;

Height of the world

Public property Bounds: TRectf read GetBounds;

Get the bounding box of the world

Public property Images: TPHXImageList read FImages write FImages;

List of images used by the ChangeImage method of the sprites

Public property Animations: TPHXAnimationList read FAnimations write FAnimations;

List of images used by the ChangeAnimation method of the sprites

Public property Shapes: TPHXShapeList read FShapes write FShapes;

List of images used by the ChangeShape method of the sprites


Generated by PasDoc 0.13.0 on 2013-08-26 11:02:43