Class T2DSceneManager

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type T2DSceneManager = class(TCastleSceneManager)

Description

Scene manager best suited for 2D worlds.

Features:

  • By default creates camera looks down in -Z, good when your world spans in XY plane. And TUniversalCamera.NavigationType is ntNone, which means that no automatic way to move camera in the world is possible, you want to program your own movement for 2D.

  • Sets 2D projection (regardless of viewpoints defined in MainScene).

  • Sets RenderStyle = rs2D by default, which makes it possible to place the scene manager rendering in the middle of other 2D controls (for example, over some 2D background and before some 2D buttons.)

  • Sets Transparent = True by default, which means that background underneath will be visible. Useful for 2D games where you usually have an image or another background underneath, like TCastleImage or TCastleSimpleBackground.

Hierarchy

Overview

Fields

Public internal const DefaultProjectionSpan = 1000.0;

Methods

Protected function CalculateProjection: TProjection; override;
Public constructor Create(AOwner: TComponent); override;
Public function CreateDefaultCamera(AOwner: TComponent): TCamera; override;

Properties

Public property RenderStyle default rs2D;
Public property ProjectionAutoSize: boolean read FProjectionAutoSize write FProjectionAutoSize default true;
Public property ProjectionHeight: Single read FProjectionHeight write FProjectionHeight default 1;
Public property CurrentProjectionWidth: Single read FCurrentProjectionWidth;
Public property CurrentProjectionHeight: Single read FCurrentProjectionHeight;
Public property ProjectionSpan: Single read FProjectionSpan write FProjectionSpan default DefaultProjectionSpan;

Description

Fields

Public internal const DefaultProjectionSpan = 1000.0;
 

Methods

Protected function CalculateProjection: TProjection; override;
 
Public constructor Create(AOwner: TComponent); override;
 
Public function CreateDefaultCamera(AOwner: TComponent): TCamera; override;
 

Properties

Public property RenderStyle default rs2D;
 
Public property ProjectionAutoSize: boolean read FProjectionAutoSize write FProjectionAutoSize default true;

When True, the size of the world visible in our viewport will depend on scene manager size. ProjectionHeight is ignored then. When False, ProjectionHeight is used to determine the height of world visible in our viewport (width is automatically adjusted to follow aspect ratio of viewport size).

In all cases, CurrentProjectionWidth and CurrentProjectionHeight must be checked to see actual projection dimensions. When this is True, then CurrentProjectionWidth and CurrentProjectionHeight are determined by the scene manager size (which is also available using TUIRectangularControl.Rect method). When this is False, then CurrentProjectionHeight is equal to ProjectionHeight, and CurrentProjectionWidth is adjusted to follow aspect ratio.

Public property ProjectionHeight: Single read FProjectionHeight write FProjectionHeight default 1;
 
Public property CurrentProjectionWidth: Single read FCurrentProjectionWidth;
 
Public property CurrentProjectionHeight: Single read FCurrentProjectionHeight;
 
Public property ProjectionSpan: Single read FProjectionSpan write FProjectionSpan default DefaultProjectionSpan;