reckfellENGINE

Entity2D

A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and skew.

On this page
class Entity2DReckfellSharpInherits CanvasItem

A 2D game object, inherited by all 2D-related entities. Has a position, rotation, scale, and skew.

A 2D game object, with a transform (position, rotation, and scale). All 2D entities, including physics objects and sprites, inherit from Entity2D. Use Entity2D as a parent entity to move, scale and rotate children in a 2D project. Also gives control of the entity's render order. Note: Since both Entity2D and Control inherit from CanvasItem, they share several concepts from the class such as the CanvasItem.ZIndex and CanvasItem.Visible properties.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

Entity2DConstructor
# Entity2D
C#
public Entity2D();

Properties12

GlobalPositionProperty
# GlobalPosition
C#
public Vector2 GlobalPosition { get; set; }

Origin position in the item's canvas, excluding camera and window transforms. Assignment converts the point through the parent CanvasItem inverse transform; when a parent applies, its basis must be invertible.

GlobalRotationProperty
# GlobalRotation
C#
public float GlobalRotation { get; set; }

Global rotation in radians. See also Entity2D.Rotation.

GlobalRotationDegreesProperty
# GlobalRotationDegrees
C#
public float GlobalRotationDegrees { get; set; }

Helper property to access Entity2D.GlobalRotation in degrees instead of radians. See also Entity2D.RotationDegrees.

GlobalScaleProperty
# GlobalScale
C#
public Vector2 GlobalScale { get; set; }

Global scale. See also Entity2D.Scale.

GlobalSkewProperty
# GlobalSkew
C#
public float GlobalSkew { get; set; }

Global skew in radians. See also Entity2D.Skew.

GlobalTransformProperty
# GlobalTransform
C#
public Transform2D GlobalTransform { get; set; }

Affine transform from item-local coordinates to its canvas, including inherited CanvasItem ancestors. Does not include Camera2D, CanvasLayer or final window presentation; use GetGlobalTransformWithCanvas for the canvas stage.

PositionProperty
# Position
C#
public Vector2 Position { get; set; }

Origin position in the parent CanvasItem local space. Parent rotation and scale affect the resulting GlobalPosition. With TopLevel the parent CanvasItem transform is not inherited.

RotationProperty
# Rotation
C#
public float Rotation { get; set; }

Rotation in radians, relative to the entity's parent. See also Entity2D.GlobalRotation. Note: This property is edited in the inspector in degrees. If you want to use degrees in a script, use Entity2D.RotationDegrees.

RotationDegreesProperty
# RotationDegrees
C#
public float RotationDegrees { get; set; }

Helper property to access Entity2D.Rotation in degrees instead of radians. See also Entity2D.GlobalRotationDegrees.

ScaleProperty
# Scale
C#
public Vector2 Scale { get; set; }

The entity's scale, relative to the entity's parent. Unscaled value: (1, 1). See also Entity2D.GlobalScale. Note: Negative X scales in 2D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Reckfell, negative scales on the X axis will be changed to negative scales on the Y axis and a rotation of 180 degrees when decomposed.

SkewProperty
# Skew
C#
public float Skew { get; set; }

If set to a non-zero value, slants the entity in one direction or another. This can be used for pseudo-3D effects. See also Entity2D.GlobalSkew. Note: Skew is performed on the X axis only, and between rotation and scaling. Note: This property is edited in the inspector in degrees. If you want to use degrees in a script, use skew = deg_to_rad(value_in_degrees).

TransformProperty
# Transform
C#
public Transform2D Transform { get; set; }

Item-local affine transform: basis and translation relative to the parent CanvasItem. Hierarchy composition uses parentTransform * childTransform.

Methods33

ApplyScalevoid
# ApplyScale
C#
public void ApplyScale(Vector2 ratio);

Multiplies the current scale by the ratio vector.

Parameters
NameTypeDefault
ratioVector2—
GetAngleTofloat
# GetAngleTo
C#
public float GetAngleTo(Vector2 point);

Returns an angle in radians for a world-space point relative to this Entity2D. The implementation takes the angle of ToLocal(point) multiplied componentwise by the entity Scale. Keep the point in world coordinates; the result depends on the current transform. See also Entity2D.LookAt.

Parameters
NameTypeDefault
pointVector2—
Returns float
GetGlobalPositionVector2
# GetGlobalPosition
C#
public Vector2 GetGlobalPosition();
Returns Vector2
GetGlobalRotationfloat
# GetGlobalRotation
C#
public float GetGlobalRotation();
Returns float
GetGlobalRotationDegreesfloat
# GetGlobalRotationDegrees
C#
public float GetGlobalRotationDegrees();
Returns float
GetGlobalScaleVector2
# GetGlobalScale
C#
public Vector2 GetGlobalScale();
Returns Vector2
GetGlobalSkewfloat
# GetGlobalSkew
C#
public float GetGlobalSkew();
Returns float
GetPositionVector2
# GetPosition
C#
public Vector2 GetPosition();
Returns Vector2
GetRelativeTransformToParentTransform2D
# GetRelativeTransformToParent
C#
public Transform2D GetRelativeTransformToParent(Entity parent);

Composes the transform to the specified ancestor through an Entity2D parent chain; returns identity for the item itself. This is not a conversion between arbitrary siblings and does not include canvas/camera transforms.

Parameters
NameTypeDefault
parentEntity—
parent

The item itself or an ancestor reachable through an Entity2D chain.

Returns Transform2D

Transform from item-local space to the specified Entity2D ancestor space.

GetRotationfloat
# GetRotation
C#
public float GetRotation();
Returns float
GetRotationDegreesfloat
# GetRotationDegrees
C#
public float GetRotationDegrees();
Returns float
GetScaleVector2
# GetScale
C#
public Vector2 GetScale();
Returns Vector2
GetSkewfloat
# GetSkew
C#
public float GetSkew();
Returns float
GlobalTranslatevoid
# GlobalTranslate
C#
public void GlobalTranslate(Vector2 offset);

Adds the offset vector to the entity's global position.

Parameters
NameTypeDefault
offsetVector2—
LookAtvoid
# LookAt
C#
public void LookAt(Vector2 point);

Rotates the entity so that its local +X axis points towards the point, which is expected to use global coordinates. This method is a combination of both Entity2D.Rotate and Entity2D.GetAngleTo. point should not be the same as the entity's position, otherwise the entity always looks to the right.

Parameters
NameTypeDefault
pointVector2—
MoveLocalXvoid
# MoveLocalX
C#
public void MoveLocalX(float delta, bool scaled = false);

Applies a local translation on the entity's X axis with the amount specified in delta. If scaled is false, normalizes the movement to occur independently of the entity's Entity2D.Scale.

Parameters
NameTypeDefault
deltafloat—
scaledboolfalse
MoveLocalYvoid
# MoveLocalY
C#
public void MoveLocalY(float delta, bool scaled = false);

Applies a local translation on the entity's Y axis with the amount specified in delta. If scaled is false, normalizes the movement to occur independently of the entity's Entity2D.Scale.

Parameters
NameTypeDefault
deltafloat—
scaledboolfalse
Rotatevoid
# Rotate
C#
public void Rotate(float radians);

Applies a rotation to the entity, in radians, starting from its current rotation. This is equivalent to rotation += radians.

Parameters
NameTypeDefault
radiansfloat—
SetGlobalPositionvoid
# SetGlobalPosition
C#
public void SetGlobalPosition(Vector2 position);
Parameters
NameTypeDefault
positionVector2—
SetGlobalRotationvoid
# SetGlobalRotation
C#
public void SetGlobalRotation(float radians);
Parameters
NameTypeDefault
radiansfloat—
SetGlobalRotationDegreesvoid
# SetGlobalRotationDegrees
C#
public void SetGlobalRotationDegrees(float degrees);
Parameters
NameTypeDefault
degreesfloat—
SetGlobalScalevoid
# SetGlobalScale
C#
public void SetGlobalScale(Vector2 scale);
Parameters
NameTypeDefault
scaleVector2—
SetGlobalSkewvoid
# SetGlobalSkew
C#
public void SetGlobalSkew(float radians);
Parameters
NameTypeDefault
radiansfloat—
SetGlobalTransformvoid
# SetGlobalTransform
C#
public void SetGlobalTransform(Transform2D xform);
Parameters
NameTypeDefault
xformTransform2D—
SetPositionvoid
# SetPosition
C#
public void SetPosition(Vector2 position);
Parameters
NameTypeDefault
positionVector2—
SetRotationvoid
# SetRotation
C#
public void SetRotation(float radians);
Parameters
NameTypeDefault
radiansfloat—
SetRotationDegreesvoid
# SetRotationDegrees
C#
public void SetRotationDegrees(float degrees);
Parameters
NameTypeDefault
degreesfloat—
SetScalevoid
# SetScale
C#
public void SetScale(Vector2 scale);
Parameters
NameTypeDefault
scaleVector2—
SetSkewvoid
# SetSkew
C#
public void SetSkew(float radians);
Parameters
NameTypeDefault
radiansfloat—
SetTransformvoid
# SetTransform
C#
public void SetTransform(Transform2D xform);
Parameters
NameTypeDefault
xformTransform2D—
ToGlobalVector2
# ToGlobal
C#
public Vector2 ToGlobal(Vector2 localPoint);

Converts an item-local point to its canvas coordinates using GlobalTransform. Does not add the camera or window transform. Passing the item's own Position instead of a local point usually applies its offset twice.

Parameters
NameTypeDefault
localPointVector2—
localPoint

Point relative to this Entity2D itself, not its parent-relative Position.

Returns Vector2

Point in the item's canvas, not a screen position.

ToLocalVector2
# ToLocal
C#
public Vector2 ToLocal(Vector2 globalPoint);

Converts a point from the item's canvas to item-local coordinates using the affine inverse of GlobalTransform. This does not convert an OS screen position or a camera-transformed logical viewport point; the basis must be invertible.

Parameters
NameTypeDefault
globalPointVector2—
globalPoint

Point in this item's canvas, excluding the camera transform.

Returns Vector2

Point in the Entity2D local space.

Translatevoid
# Translate
C#
public void Translate(Vector2 offset);

Translates the entity by the given offset in local coordinates. This is equivalent to position += offset.

Parameters
NameTypeDefault
offsetVector2—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.