Node2D

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

A 2D game object, with a transform (position, rotation, and scale). All 2D nodes, including physics objects and sprites, inherit from Node2D. Use Node2D as a parent node to move, scale and rotate children in a 2D project. Also gives control of the node's render order.

@GodotBaseClass
struct Node2D {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Functions

applyScale
void applyScale(Vector2 ratio)

Multiplies the current scale by the ratio vector.

getAngleTo
double getAngleTo(Vector2 point)

Returns the angle between the node and the point in radians.

getGlobalPosition
Vector2 getGlobalPosition()
getGlobalRotation
double getGlobalRotation()
getGlobalRotationDegrees
double getGlobalRotationDegrees()
getGlobalScale
Vector2 getGlobalScale()
getPosition
Vector2 getPosition()
getRelativeTransformToParent
Transform2D getRelativeTransformToParent(Node parent)

Returns the Transform2D relative to this node's parent.

getRotation
double getRotation()
getRotationDegrees
double getRotationDegrees()
getScale
Vector2 getScale()
getZIndex
long getZIndex()
globalTranslate
void globalTranslate(Vector2 offset)

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

isZRelative
bool isZRelative()
lookAt
void lookAt(Vector2 point)

Rotates the node so it points towards the point, which is expected to use global coordinates.

moveLocalX
void moveLocalX(double delta, bool scaled)

Applies a local translation on the node's X axis based on the Node._process's delta. If scaled is false, normalizes the movement.

moveLocalY
void moveLocalY(double delta, bool scaled)

Applies a local translation on the node's Y axis based on the Node._process's delta. If scaled is false, normalizes the movement.

opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(Node2D other)
opEquals
bool opEquals(typeof(null) n)
rotate
void rotate(double radians)

Applies a rotation to the node, in radians, starting from its current rotation.

setGlobalPosition
void setGlobalPosition(Vector2 position)
setGlobalRotation
void setGlobalRotation(double radians)
setGlobalRotationDegrees
void setGlobalRotationDegrees(double degrees)
setGlobalScale
void setGlobalScale(Vector2 scale)
setGlobalTransform
void setGlobalTransform(Transform2D xform)
setPosition
void setPosition(Vector2 position)
setRotation
void setRotation(double radians)
setRotationDegrees
void setRotationDegrees(double degrees)
setScale
void setScale(Vector2 scale)
setTransform
void setTransform(Transform2D xform)
setZAsRelative
void setZAsRelative(bool enable)
setZIndex
void setZIndex(long z_index)
toGlobal
Vector2 toGlobal(Vector2 local_point)

Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the Node2D it is called on. e.g. Applying this method to the positions of child nodes will correctly transform their positions into the global coordinate space, but applying it to a node's own position will give an incorrect result, as it will incorporate the node's own transformation into its global position.

toHash
size_t toHash()
toLocal
Vector2 toLocal(Vector2 global_point)

Transforms the provided global position into a position in local coordinate space. The output will be local relative to the Node2D it is called on. e.g. It is appropriate for determining the positions of child nodes, but it is not appropriate for determining its own position relative to its parent.

translate
void translate(Vector2 offset)

Translates the node by the given offset in local coordinates.

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

globalPosition
Vector2 globalPosition [@property getter]
Vector2 globalPosition [@property setter]

Global position.

globalRotation
double globalRotation [@property getter]
double globalRotation [@property setter]

Global rotation in radians.

globalRotationDegrees
double globalRotationDegrees [@property getter]
double globalRotationDegrees [@property setter]

Global rotation in degrees.

globalScale
Vector2 globalScale [@property getter]
Vector2 globalScale [@property setter]

Global scale.

globalTransform
Transform2D globalTransform [@property getter]
Transform2D globalTransform [@property setter]

Global Transform2D.

position
Vector2 position [@property getter]
Vector2 position [@property setter]

Position, relative to the node's parent.

rotation
double rotation [@property getter]
double rotation [@property setter]

Rotation in radians, relative to the node's parent.

rotationDegrees
double rotationDegrees [@property getter]
double rotationDegrees [@property setter]

Rotation in degrees, relative to the node's parent.

scale
Vector2 scale [@property getter]
Vector2 scale [@property setter]

The node's scale. Unscaled value: (1, 1).

transform
Transform2D transform [@property getter]
Transform2D transform [@property setter]

Local Transform2D.

zAsRelative
bool zAsRelative [@property getter]
bool zAsRelative [@property setter]

If true, the node's Z index is relative to its parent's Z index. If this node's Z index is 2 and its parent's effective Z index is 3, then this node's effective Z index will be 2 + 3 = 5.

zIndex
long zIndex [@property getter]
long zIndex [@property setter]

Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others. Must be between constant VisualServer.CANVAS_ITEM_Z_MIN and constant VisualServer.CANVAS_ITEM_Z_MAX (inclusive).

Static functions

_new
Node2D _new()

Construct a new instance of Node2D. Note: use memnew!Node2D instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta