Documentation
¶
Overview ¶
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.
Note: Since both graphics.gd/classdb/Node2D and graphics.gd/classdb/Control inherit from graphics.gd/classdb/CanvasItem, they share several concepts from the class such as the graphics.gd/classdb/CanvasItem.Instance.ZIndex and graphics.gd/classdb/CanvasItem.Instance.Visible properties.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) ApplyScale(ratio Vector2.XY)
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode2D() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) GetAngleTo(point Vector2.XY) Angle.Radians
- func (self Instance) GetRelativeTransformToParent(parent Node.Instance) Transform2D.OriginXY
- func (self Instance) GlobalPosition() Vector2.XY
- func (self Instance) GlobalRotation() Angle.Radians
- func (self Instance) GlobalRotationDegrees() Angle.Degrees
- func (self Instance) GlobalScale() Vector2.XY
- func (self Instance) GlobalSkew() Float.X
- func (self Instance) GlobalTranslate(offset Vector2.XY)
- func (self Instance) ID() ID
- func (self Instance) LookAt(point Vector2.XY)
- func (self Instance) MoveLocalX(delta Float.X)
- func (self Instance) MoveLocalY(delta Float.X)
- func (self Instance) Position() Vector2.XY
- func (self Instance) Rotate(radians Angle.Radians)
- func (self Instance) Rotation() Angle.Radians
- func (self Instance) RotationDegrees() Angle.Degrees
- func (self Instance) Scale() Vector2.XY
- func (self Instance) SetGlobalPosition(value Vector2.XY)
- func (self Instance) SetGlobalRotation(value Angle.Radians)
- func (self Instance) SetGlobalRotationDegrees(value Angle.Degrees)
- func (self Instance) SetGlobalScale(value Vector2.XY)
- func (self Instance) SetGlobalSkew(value Float.X)
- func (self Instance) SetGlobalTransform(value Transform2D.OriginXY)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPosition(value Vector2.XY)
- func (self Instance) SetRotation(value Angle.Radians)
- func (self Instance) SetRotationDegrees(value Angle.Degrees)
- func (self Instance) SetScale(value Vector2.XY)
- func (self Instance) SetSkew(value Float.X)
- func (self Instance) SetTransform(value Transform2D.OriginXY)
- func (self Instance) Skew() Float.X
- func (self Instance) ToGlobal(local_point Vector2.XY) Vector2.XY
- func (self Instance) ToLocal(global_point Vector2.XY) Vector2.XY
- func (self Instance) Translate(offset Vector2.XY)
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Expanded ¶
func (Expanded) MoveLocalX ¶
Applies a local translation on the node's X axis based on the graphics.gd/classdb/Node.Instance.Process's 'delta'. If 'scaled' is false, normalizes the movement.
func (Expanded) MoveLocalY ¶
Applies a local translation on the node's Y axis based on the graphics.gd/classdb/Node.Instance.Process's 'delta'. If 'scaled' is false, normalizes the movement.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) ApplyScale ¶
Multiplies the current scale by the 'ratio' vector.
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) GetAngleTo ¶
Returns the angle between the node and the 'point' in radians.
func (Instance) GetRelativeTransformToParent ¶
func (self Instance) GetRelativeTransformToParent(parent Node.Instance) Transform2D.OriginXY
Returns the [Transform2D.OriginXY] relative to this node's parent.
func (Instance) GlobalPosition ¶
func (Instance) GlobalRotation ¶
func (Instance) GlobalRotationDegrees ¶
func (Instance) GlobalScale ¶
func (Instance) GlobalSkew ¶
func (Instance) GlobalTranslate ¶
Adds the 'offset' vector to the node's global position.
func (Instance) LookAt ¶
Rotates the node so that its local +X axis points towards the 'point', which is expected to use global coordinates.
'point' should not be the same as the node's position, otherwise the node always looks to the right.
func (Instance) MoveLocalX ¶
Applies a local translation on the node's X axis based on the graphics.gd/classdb/Node.Instance.Process's 'delta'. If 'scaled' is false, normalizes the movement.
func (Instance) MoveLocalY ¶
Applies a local translation on the node's Y axis based on the graphics.gd/classdb/Node.Instance.Process's 'delta'. If 'scaled' is false, normalizes the movement.
func (Instance) Rotate ¶
Applies a rotation to the node, in radians, starting from its current rotation.
func (Instance) RotationDegrees ¶
func (Instance) SetGlobalPosition ¶
func (Instance) SetGlobalRotation ¶
func (Instance) SetGlobalRotationDegrees ¶
func (Instance) SetGlobalScale ¶
func (Instance) SetGlobalSkew ¶
func (Instance) SetGlobalTransform ¶
func (self Instance) SetGlobalTransform(value Transform2D.OriginXY)
func (Instance) SetPosition ¶
func (Instance) SetRotation ¶
func (Instance) SetRotationDegrees ¶
func (Instance) SetTransform ¶
func (self Instance) SetTransform(value Transform2D.OriginXY)
func (Instance) ToGlobal ¶
Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the graphics.gd/classdb/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.
func (Instance) ToLocal ¶
Transforms the provided global position into a position in local coordinate space. The output will be local relative to the graphics.gd/classdb/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.