Node2D

package
v0.0.0-...-ae8aae0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package Node2D provides methods for working with Node2D object instances.

Index

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 Any

type Any interface {
	gd.IsClass
	AsNode2D() Instance
}

type Instance

type Instance [1]gdclass.Node2D

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.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) ApplyScale

func (self Instance) ApplyScale(ratio Vector2.XY)

Multiplies the current scale by the [param ratio] vector.

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode2D

func (self Instance) AsNode2D() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) GetAngleTo

func (self Instance) GetAngleTo(point Vector2.XY) Float.X

Returns the angle between the node and the [param point] in radians. [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/node2d_get_angle_to.png]Illustration of the returned angle.[/url]

func (Instance) GetRelativeTransformToParent

func (self Instance) GetRelativeTransformToParent(parent [1]gdclass.Node) Transform2D.OriginXY

Returns the [Transform2D] relative to this node's parent.

func (Instance) GlobalPosition

func (self Instance) GlobalPosition() Vector2.XY

func (Instance) GlobalRotation

func (self Instance) GlobalRotation() Float.X

func (Instance) GlobalRotationDegrees

func (self Instance) GlobalRotationDegrees() Float.X

func (Instance) GlobalScale

func (self Instance) GlobalScale() Vector2.XY

func (Instance) GlobalSkew

func (self Instance) GlobalSkew() Float.X

func (Instance) GlobalTranslate

func (self Instance) GlobalTranslate(offset Vector2.XY)

Adds the [param offset] vector to the node's global position.

func (Instance) LookAt

func (self Instance) LookAt(point Vector2.XY)

Rotates the node so that its local +X axis points towards the [param point], which is expected to use global coordinates. [param point] should not be the same as the node's position, otherwise the node always looks to the right.

func (Instance) MoveLocalX

func (self Instance) MoveLocalX(delta Float.X)

Applies a local translation on the node's X axis based on the [method Node._process]'s [param delta]. If [param scaled] is [code]false[/code], normalizes the movement.

func (Instance) MoveLocalY

func (self Instance) MoveLocalY(delta Float.X)

Applies a local translation on the node's Y axis based on the [method Node._process]'s [param delta]. If [param scaled] is [code]false[/code], normalizes the movement.

func (Instance) Position

func (self Instance) Position() Vector2.XY

func (Instance) Rotate

func (self Instance) Rotate(radians Float.X)

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

func (Instance) Rotation

func (self Instance) Rotation() Float.X

func (Instance) RotationDegrees

func (self Instance) RotationDegrees() Float.X

func (Instance) Scale

func (self Instance) Scale() Vector2.XY

func (Instance) SetGlobalPosition

func (self Instance) SetGlobalPosition(value Vector2.XY)

func (Instance) SetGlobalRotation

func (self Instance) SetGlobalRotation(value Float.X)

func (Instance) SetGlobalRotationDegrees

func (self Instance) SetGlobalRotationDegrees(value Float.X)

func (Instance) SetGlobalScale

func (self Instance) SetGlobalScale(value Vector2.XY)

func (Instance) SetGlobalSkew

func (self Instance) SetGlobalSkew(value Float.X)

func (Instance) SetGlobalTransform

func (self Instance) SetGlobalTransform(value Transform2D.OriginXY)

func (Instance) SetPosition

func (self Instance) SetPosition(value Vector2.XY)

func (Instance) SetRotation

func (self Instance) SetRotation(value Float.X)

func (Instance) SetRotationDegrees

func (self Instance) SetRotationDegrees(value Float.X)

func (Instance) SetScale

func (self Instance) SetScale(value Vector2.XY)

func (Instance) SetSkew

func (self Instance) SetSkew(value Float.X)

func (Instance) SetTransform

func (self Instance) SetTransform(value Transform2D.OriginXY)

func (Instance) Skew

func (self Instance) Skew() Float.X

func (Instance) ToGlobal

func (self Instance) ToGlobal(local_point Vector2.XY) Vector2.XY

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.

func (Instance) ToLocal

func (self Instance) ToLocal(global_point Vector2.XY) Vector2.XY

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.

func (Instance) Translate

func (self Instance) Translate(offset Vector2.XY)

Translates the node by the given [param offset] in local coordinates.

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL