Ctrl+K

TransformComponent

Declaration

public class Strawberry.Components.TransformComponent

Manages the 2D transformation of an entity, including position, rotation, scale, and origin. Supports parent-child hierarchies, allowing transformations to be inherited or orbit around a parent.

Inherits: Strawberry.Core.BaseComponent

Constructors

TransformComponent

Initializes a new instance of the TransformComponent class. Sets the default scale to (1, 1) and the PositionType to Global.

void TransformComponent()

Properties

Position

Gets or sets the world position of the entity. When getting, this calculates the final world position based on the PositionType and parent hierarchy. When setting, this updates the LocalPosition.

Vector2 Position { get set }

LocalPosition

Gets or sets the local position of the entity, relative to its parent. If the entity has no parent, this is equivalent to the global position.

Vector2 LocalPosition { get set }

Scale

Gets or sets the 2D scale of the entity.

Vector2 Scale { get set }

Angle

Gets or sets the rotation angle of the entity. If HeadAsParent is true and a parent exists, getting this property returns the parent's angle.

float Angle { get set }

Direction

Gets the rotation direction of the entity as a double, equivalent to Angle.

double Direction { get }

HeadAsParent

Gets or sets a value indicating whether this entity should inherit the rotation angle from its parent entity.

bool HeadAsParent { get set }

PositionType

Gets or sets the coordinate space used for this transform's position. Defaults to Global upon construction.

PositionType PositionType { get set }

Origin

Gets or sets the origin point (pivot) for rotation and scaling.

Vector2 Origin { get set }

RotateAroundParent

Gets or sets a value indicating whether the local position should be rotated by the parent's angle before applying the parent's offset. This creates an orbiting effect around the parent.

bool RotateAroundParent { get set }