A Polygon2D is defined by a set of points. Each point is connected to the next, with the final point being connected to the first, resulting in a closed polygon. Polygon2Ds can be filled with color (solid or gradient) or filled with a given texture.

Note: By default, Godot can only draw up to 4,096 polygon points at a time. To increase this limit, open the Project Settings and increase and .

Constructor

@:native("new")new()

Variables

@:native("Antialiased")antialiased:Bool

If true, attempts to perform antialiasing for polygon edges by drawing a thin OpenGL smooth line on the edges.

Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.

@:native("Bones")bones:Array

@:native("Color")color:Color

The polygon's fill color. If texture is defined, it will be multiplied by this color. It will also be the default color for vertices not set in vertex_colors.

@:native("InternalVertexCount")internalVertexCount:Int

@:native("InvertBorder")invertBorder:Single

Added padding applied to the bounding box when using invert. Setting this value too small may result in a "Bad Polygon" error.

@:native("InvertEnable")invertEnable:Bool

If true, polygon will be inverted, containing the area outside the defined points and extending to the invert_border.

@:native("Offset")offset:Vector2

The offset applied to each vertex.

@:native("Polygon")polygon:NativeArray<Vector2>

The polygon's list of vertices. The final point will be connected to the first.

Note: This returns a copy of the godot.Vector2 rather than a reference.

@:native("Polygons")polygons:Array

@:native("Skeleton")skeleton:NodePath

@:native("Texture")texture:Texture

The polygon's fill texture. Use uv to set texture coordinates.

@:native("TextureOffset")textureOffset:Vector2

Amount to offset the polygon's texture. If (0, 0) the texture's origin (its top-left corner) will be placed at the polygon's position.

@:native("TextureRotation")textureRotation:Single

The texture's rotation in radians.

@:native("TextureRotationDegrees")textureRotationDegrees:Single

The texture's rotation in degrees.

@:native("TextureScale")textureScale:Vector2

Amount to multiply the uv coordinates when using a texture. Larger values make the texture smaller, and vice versa.

@:native("Uv")uv:NativeArray<Vector2>

Texture coordinates for each vertex of the polygon. There should be one uv per polygon vertex. If there are fewer, undefined vertices will use (0, 0).

@:native("VertexColors")vertexColors:NativeArray<Color>

Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use color.

Methods

@:native("AddBone")addBone(path:NodePath, weights:HaxeArray<Single>):Void

Adds a bone with the specified path and weights.

@:native("ClearBones")clearBones():Void

Removes all bones from this godot.Polygon2D.

@:native("EraseBone")eraseBone(index:Int):Void

Removes the specified bone from this godot.Polygon2D.

@:native("GetAntialiased")getAntialiased():Bool

@:native("GetBoneCount")getBoneCount():Int

Returns the number of bones in this godot.Polygon2D.

@:native("GetBonePath")getBonePath(index:Int):NodePath

Returns the path to the node associated with the specified bone.

inlinegetBoneWeights(index:Int):Array<Single>

Returns the height values of the specified bone.

@:native("GetColor")getColor():Color

@:native("GetInternalVertexCount")getInternalVertexCount():Int

@:native("GetInvert")getInvert():Bool

@:native("GetInvertBorder")getInvertBorder():Single

@:native("GetOffset")getOffset():Vector2

inlinegetPolygon():Array<Vector2>

@:native("GetPolygons")getPolygons():Array

@:native("GetSkeleton")getSkeleton():NodePath

@:native("GetTexture")getTexture():Texture

@:native("GetTextureOffset")getTextureOffset():Vector2

@:native("GetTextureRotation")getTextureRotation():Single

@:native("GetTextureRotationDegrees")getTextureRotationDegrees():Single

@:native("GetTextureScale")getTextureScale():Vector2

inlinegetUv():Array<Vector2>

inlinegetVertexColors():Array<Color>

@:native("SetAntialiased")setAntialiased(antialiased:Bool):Void

@:native("SetBonePath")setBonePath(index:Int, path:NodePath):Void

Sets the path to the node associated with the specified bone.

@:native("SetBoneWeights")setBoneWeights(index:Int, weights:HaxeArray<Single>):Void

Sets the weight values for the specified bone.

@:native("SetColor")setColor(color:Color):Void

@:native("SetInternalVertexCount")setInternalVertexCount(internalVertexCount:Int):Void

@:native("SetInvert")setInvert(invert:Bool):Void

@:native("SetInvertBorder")setInvertBorder(invertBorder:Single):Void

@:native("SetOffset")setOffset(offset:Vector2):Void

@:native("SetPolygon")setPolygon(polygon:HaxeArray<Vector2>):Void

@:native("SetPolygons")setPolygons(polygons:Array):Void

@:native("SetSkeleton")setSkeleton(skeleton:NodePath):Void

@:native("SetTexture")setTexture(texture:Texture):Void

@:native("SetTextureOffset")setTextureOffset(textureOffset:Vector2):Void

@:native("SetTextureRotation")setTextureRotation(textureRotation:Single):Void

@:native("SetTextureRotationDegrees")setTextureRotationDegrees(textureRotation:Single):Void

@:native("SetTextureScale")setTextureScale(textureScale:Vector2):Void

@:native("SetUv")setUv(uv:HaxeArray<Vector2>):Void

@:native("SetVertexColors")setVertexColors(vertexColors:HaxeArray<Color>):Void

Inherited Variables

Defined by Node2D

@:native("GlobalPosition")globalPosition:Vector2

Global position.

@:native("GlobalRotation")globalRotation:Single

Global rotation in radians.

@:native("GlobalRotationDegrees")globalRotationDegrees:Single

Global rotation in degrees.

@:native("GlobalScale")globalScale:Vector2

Global scale.

@:native("GlobalTransform")globalTransform:Transform2D

@:native("Position")position:Vector2

Position, relative to the node's parent.

@:native("Rotation")rotation:Single

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

@:native("RotationDegrees")rotationDegrees:Single

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

@:native("Scale")scale:Vector2

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

@:native("Transform")transform:Transform2D

@:native("ZAsRelative")zAsRelative:Bool

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.

@:native("ZIndex")zIndex:Int

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 godot.VisualServer.canvasItemZMin and godot.VisualServer.canvasItemZMax (inclusive).

Defined by CanvasItem

@:native("LightMask")lightMask:Int

The rendering layers in which this godot.CanvasItem responds to godot.Light2D nodes.

@:native("Material")material:Material

The material applied to textures on this godot.CanvasItem.

@:native("Modulate")modulate:Color

The color applied to textures on this godot.CanvasItem.

read onlyonDraw:Signal<() ‑> Void>

draw signal.

read onlyonHide:Signal<() ‑> Void>

hide signal.

read onlyonItemRectChanged:Signal<() ‑> Void>

item_rect_changed signal.

read onlyonVisibilityChanged:Signal<() ‑> Void>

visibility_changed signal.

@:native("SelfModulate")selfModulate:Color

The color applied to textures on this godot.CanvasItem. This is not inherited by children godot.CanvasItems.

@:native("ShowBehindParent")showBehindParent:Bool

If true, the object draws behind its parent.

@:native("ShowOnTop")showOnTop:Bool

If true, the object draws on top of its parent.

@:native("UseParentMaterial")useParentMaterial:Bool

If true, the parent godot.CanvasItem's godot.CanvasItem.material property is used as this one's material.

@:native("Visible")visible:Bool

If true, this godot.CanvasItem is drawn. The node is only visible if all of its antecedents are visible as well (in other words, godot.CanvasItem.isVisibleInTree must return true).

Note: For controls that inherit godot.Popup, the correct way to make them visible is to call one of the multiple popup*() functions instead.

Defined by Node

@:native("_ImportPath")_ImportPath:NodePath

@:native("CustomMultiplayer")customMultiplayer:MultiplayerAPI

The override to the default godot.MultiplayerAPI. Set to null to use the default godot.SceneTree one.

@:native("EditorDescription")editorDescription:String

@:native("Filename")filename:String

If a scene is instantiated from a file, its topmost node contains the absolute file path from which it was loaded in godot.Node.filename (e.g. res://levels/1.tscn). Otherwise, godot.Node.filename is set to an empty string.

@:native("Multiplayer")read onlymultiplayer:MultiplayerAPI

The godot.MultiplayerAPI instance associated with this node. Either the godot.Node.customMultiplayer, or the default SceneTree one (if inside tree).

@:native("Name")name:String

The name of the node. This name is unique among the siblings (other child nodes from the same parent). When set to an existing name, the node will be automatically renamed.

Note: Auto-generated names might include the @ character, which is reserved for unique names when using godot.Node.addChild. When setting the name manually, any @ will be removed.

read onlyonReady:Signal<() ‑> Void>

ready signal.

read onlyonRenamed:Signal<() ‑> Void>

renamed signal.

read onlyonTreeEntered:Signal<() ‑> Void>

tree_entered signal.

read onlyonTreeExited:Signal<() ‑> Void>

tree_exited signal.

read onlyonTreeExiting:Signal<() ‑> Void>

tree_exiting signal.

@:native("Owner")owner:Node

The node owner. A node can have any other node as owner (as long as it is a valid parent, grandparent, etc. ascending in the tree). When saving a node (using godot.PackedScene), all the nodes it owns will be saved with it. This allows for the creation of complex godot.SceneTrees, with instancing and subinstancing.

Note: If you want a child to be persisted to a godot.PackedScene, you must set godot.Node.owner in addition to calling godot.Node.addChild. This is typically relevant for [https://docs.godotengine.org/en/3.4/tutorials/misc/running_code_in_the_editor.html](tool scripts) and [https://docs.godotengine.org/en/3.4/tutorials/plugins/editor/index.html](editor plugins). If godot.Node.addChild is called without setting godot.Node.owner, the newly added godot.Node will not be visible in the scene tree, though it will be visible in the 2D/3D view.

@:native("PauseMode")pauseMode:Node_PauseModeEnum

Pause mode. How the node will behave if the godot.SceneTree is paused.

@:native("ProcessPriority")processPriority:Int

The node's priority in the execution order of the enabled processing callbacks (i.e. godot.Node.notificationProcess, godot.Node.notificationPhysicsProcess and their internal counterparts). Nodes whose process priority value is lower will have their processing callbacks executed first.

Defined by Object

@:native("DynamicObject")read onlydynamicObject:Dynamic

Gets a new godot.DynamicGodotObject associated with this instance.

@:native("NativeInstance")read onlynativeInstance:IntPtr

The pointer to the native instance of this godot.Object.

read onlyonScriptChanged:Signal<() ‑> Void>

script_changed signal.

Inherited Methods

Defined by Node2D

@:native("ApplyScale")applyScale(ratio:Vector2):Void

Multiplies the current scale by the ratio vector.

@:native("GetAngleTo")getAngleTo(point:Vector2):Single

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

[https://raw.githubusercontent.com/godotengine/godot-docs/master/img/node2d_get_angle_to.png](Illustration of the returned angle.)

@:native("GetGlobalPosition")getGlobalPosition():Vector2

@:native("GetGlobalRotation")getGlobalRotation():Single

@:native("GetGlobalRotationDegrees")getGlobalRotationDegrees():Single

@:native("GetGlobalScale")getGlobalScale():Vector2

@:native("GetPosition")getPosition():Vector2

@:native("GetRelativeTransformToParent")getRelativeTransformToParent(parent:Node):Transform2D

Returns the godot.Transform2D relative to this node's parent.

@:native("GetRotation")getRotation():Single

@:native("GetRotationDegrees")getRotationDegrees():Single

@:native("GetScale")getScale():Vector2

@:native("GetZIndex")getZIndex():Int

@:native("GlobalTranslate")globalTranslate(offset:Vector2):Void

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

@:native("IsZRelative")isZRelative():Bool

@:native("LookAt")lookAt(point:Vector2):Void

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

@:native("MoveLocalX")moveLocalX(delta:Single, ?scaled:Bool):Void

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

@:native("MoveLocalY")moveLocalY(delta:Single, ?scaled:Bool):Void

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

@:native("Rotate")rotate(radians:Single):Void

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

@:native("SetGlobalPosition")setGlobalPosition(position:Vector2):Void

@:native("SetGlobalRotation")setGlobalRotation(radians:Single):Void

@:native("SetGlobalRotationDegrees")setGlobalRotationDegrees(degrees:Single):Void

@:native("SetGlobalScale")setGlobalScale(scale:Vector2):Void

@:native("SetGlobalTransform")setGlobalTransform(xform:Transform2D):Void

@:native("SetPosition")setPosition(position:Vector2):Void

@:native("SetRotation")setRotation(radians:Single):Void

@:native("SetRotationDegrees")setRotationDegrees(degrees:Single):Void

@:native("SetScale")setScale(scale:Vector2):Void

@:native("SetTransform")setTransform(xform:Transform2D):Void

@:native("SetZAsRelative")setZAsRelative(enable:Bool):Void

@:native("SetZIndex")setZIndex(zIndex:Int):Void

@:native("ToGlobal")toGlobal(localPoint:Vector2):Vector2

Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the godot.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.

@:native("ToLocal")toLocal(globalPoint:Vector2):Vector2

Transforms the provided global position into a position in local coordinate space. The output will be local relative to the godot.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.

@:native("Translate")translate(offset:Vector2):Void

Translates the node by the given offset in local coordinates.

Defined by CanvasItem

@:native("_Draw")_Draw():Void

Overridable function called by the engine (if defined) to draw the canvas item.

@:native("DrawArc")drawArc(center:Vector2, radius:Single, startAngle:Single, endAngle:Single, pointCount:Int, color:Color, ?width:Single, ?antialiased:Bool):Void

Draws a unfilled arc between the given angles. The larger the value of point_count, the smoother the curve. See also godot.CanvasItem.drawCircle.

Note: Line drawing is not accelerated by batching if antialiased is true.

Note: Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedRegularPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.

@:native("DrawChar")drawChar(font:Font, position:Vector2, char:String, next:String, ?modulate:Color):Single

Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character.

Parameters:

modulate

If the parameter is null, then the default value is new Color(1, 1, 1, 1)

@:native("DrawCircle")drawCircle(position:Vector2, radius:Single, color:Color):Void

Draws a colored, filled circle. See also godot.CanvasItem.drawArc, godot.CanvasItem.drawPolyline and godot.CanvasItem.drawPolygon.

Note: Built-in antialiasing is not provided for godot.CanvasItem.drawCircle. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedRegularPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.

@:native("DrawColoredPolygon")drawColoredPolygon(points:Array<Vector2>, color:Color, ?uvs:Array<Vector2>, ?texture:Texture, ?normalMap:Texture, ?antialiased:Bool):Void

Draws a colored polygon of any amount of points, convex or concave. Unlike godot.CanvasItem.drawPolygon, a single color must be specified for the whole polygon.

Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.

Parameters:

uvs

If the parameter is null, then the default value is Array.Empty<Vector2>()

@:native("DrawLine")drawLine(from:Vector2, to:Vector2, color:Color, ?width:Single, ?antialiased:Bool):Void

Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. See also godot.CanvasItem.drawMultiline and godot.CanvasItem.drawPolyline.

Note: Line drawing is not accelerated by batching if antialiased is true.

Note: Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.

@:native("DrawMesh")drawMesh(mesh:Mesh, texture:Texture, ?normalMap:Texture, ?transform:Transform2D, ?modulate:Color):Void

Draws a godot.Mesh in 2D, using the provided texture. See godot.MeshInstance2D for related documentation.

Parameters:

transform

If the parameter is null, then the default value is Transform2D.Identity

modulate

If the parameter is null, then the default value is new Color(1, 1, 1, 1)

@:native("DrawMultiline")drawMultiline(points:Array<Vector2>, color:Color, ?width:Single, ?antialiased:Bool):Void

Draws multiple disconnected lines with a uniform color. When drawing large amounts of lines, this is faster than using individual godot.CanvasItem.drawLine calls. To draw interconnected lines, use godot.CanvasItem.drawPolyline instead.

Note: width and antialiased are currently not implemented and have no effect. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.

@:native("DrawMultilineColors")drawMultilineColors(points:Array<Vector2>, colors:Array<Color>, ?width:Single, ?antialiased:Bool):Void

Draws multiple disconnected lines with a uniform width and segment-by-segment coloring. Colors assigned to line segments match by index between points and colors. When drawing large amounts of lines, this is faster than using individual godot.CanvasItem.drawLine calls. To draw interconnected lines, use godot.CanvasItem.drawPolylineColors instead.

Note: width and antialiased are currently not implemented and have no effect. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.

@:native("DrawMultimesh")drawMultimesh(multimesh:MultiMesh, texture:Texture, ?normalMap:Texture):Void

Draws a godot.MultiMesh in 2D with the provided texture. See godot.MultiMeshInstance2D for related documentation.

@:native("DrawPolygon")drawPolygon(points:Array<Vector2>, colors:Array<Color>, ?uvs:Array<Vector2>, ?texture:Texture, ?normalMap:Texture, ?antialiased:Bool):Void

Draws a solid polygon of any amount of points, convex or concave. Unlike godot.CanvasItem.drawColoredPolygon, each point's color can be changed individually. See also godot.CanvasItem.drawPolyline and godot.CanvasItem.drawPolylineColors.

Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.

Parameters:

uvs

If the parameter is null, then the default value is Array.Empty<Vector2>()

@:native("DrawPolyline")drawPolyline(points:Array<Vector2>, color:Color, ?width:Single, ?antialiased:Bool):Void

Draws interconnected line segments with a uniform color and width and optional antialiasing. When drawing large amounts of lines, this is faster than using individual godot.CanvasItem.drawLine calls. To draw disconnected lines, use godot.CanvasItem.drawMultiline instead. See also godot.CanvasItem.drawPolygon.

Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.

@:native("DrawPolylineColors")drawPolylineColors(points:Array<Vector2>, colors:Array<Color>, ?width:Single, ?antialiased:Bool):Void

Draws interconnected line segments with a uniform width and segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between points and colors. When drawing large amounts of lines, this is faster than using individual godot.CanvasItem.drawLine calls. To draw disconnected lines, use godot.CanvasItem.drawMultilineColors instead. See also godot.CanvasItem.drawPolygon.

Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.

@:native("DrawPrimitive")drawPrimitive(points:Array<Vector2>, colors:Array<Color>, uvs:Array<Vector2>, ?texture:Texture, ?width:Single, ?normalMap:Texture):Void

Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. See also godot.CanvasItem.drawLine, godot.CanvasItem.drawPolyline, godot.CanvasItem.drawPolygon, and godot.CanvasItem.drawRect.

@:native("DrawRect")drawRect(rect:Rect2, color:Color, ?filled:Bool, ?width:Single, ?antialiased:Bool):Void

Draws a rectangle. If filled is true, the rectangle will be filled with the color specified. If filled is false, the rectangle will be drawn as a stroke with the color and width specified. If antialiased is true, the lines will attempt to perform antialiasing using OpenGL line smoothing.

Note: width and antialiased are only effective if filled is false.

Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.

@:native("DrawSetTransform")drawSetTransform(position:Vector2, rotation:Single, scale:Vector2):Void

Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.

@:native("DrawSetTransformMatrix")drawSetTransformMatrix(xform:Transform2D):Void

Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.

@:native("DrawString")drawString(font:Font, position:Vector2, text:String, ?modulate:Color, ?clipW:Int):Void

Draws text using the specified font at the position (bottom-left corner using the baseline of the font). The text will have its color multiplied by modulate. If clip_w is greater than or equal to 0, the text will be clipped if it exceeds the specified width.

Example using the default project font:


# If using this method in a script that redraws constantly, move the
# `default_font` declaration to a member variable assigned in `_ready()`
# so the Control is only created once.
var default_font = Control.new().get_font("font")
draw_string(default_font, Vector2(64, 64), "Hello world")

See also godot.Font.draw.

Parameters:

modulate

If the parameter is null, then the default value is new Color(1, 1, 1, 1)

@:native("DrawStyleBox")drawStyleBox(styleBox:StyleBox, rect:Rect2):Void

Draws a styled rectangle.

@:native("DrawTexture")drawTexture(texture:Texture, position:Vector2, ?modulate:Color, ?normalMap:Texture):Void

Draws a texture at a given position.

Parameters:

modulate

If the parameter is null, then the default value is new Color(1, 1, 1, 1)

@:native("DrawTextureRect")drawTextureRect(texture:Texture, rect:Rect2, tile:Bool, ?modulate:Color, ?transpose:Bool, ?normalMap:Texture):Void

Draws a textured rectangle at a given position, optionally modulated by a color. If transpose is true, the texture will have its X and Y coordinates swapped.

Parameters:

modulate

If the parameter is null, then the default value is new Color(1, 1, 1, 1)

@:native("DrawTextureRectRegion")drawTextureRectRegion(texture:Texture, rect:Rect2, srcRect:Rect2, ?modulate:Color, ?transpose:Bool, ?normalMap:Texture, ?clipUv:Bool):Void

Draws a textured rectangle region at a given position, optionally modulated by a color. If transpose is true, the texture will have its X and Y coordinates swapped.

Parameters:

modulate

If the parameter is null, then the default value is new Color(1, 1, 1, 1)

@:native("ForceUpdateTransform")forceUpdateTransform():Void

Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.

@:native("GetCanvas")getCanvas():RID

Returns the godot.RID of the godot.World2D canvas where this item is in.

@:native("GetCanvasItem")getCanvasItem():RID

Returns the canvas item RID used by godot.VisualServer for this item.

@:native("GetCanvasTransform")getCanvasTransform():Transform2D

Returns the transform matrix of this item's canvas.

@:native("GetGlobalMousePosition")getGlobalMousePosition():Vector2

Returns the global position of the mouse.

@:native("GetGlobalTransform")getGlobalTransform():Transform2D

Returns the global transform matrix of this item.

@:native("GetGlobalTransformWithCanvas")getGlobalTransformWithCanvas():Transform2D

Returns the global transform matrix of this item in relation to the canvas.

@:native("GetLightMask")getLightMask():Int

@:native("GetLocalMousePosition")getLocalMousePosition():Vector2

Returns the mouse position relative to this item's position.

@:native("GetMaterial")getMaterial():Material

@:native("GetModulate")getModulate():Color

@:native("GetSelfModulate")getSelfModulate():Color

@:native("GetTransform")getTransform():Transform2D

Returns the transform matrix of this item.

@:native("GetUseParentMaterial")getUseParentMaterial():Bool

@:native("GetViewportRect")getViewportRect():Rect2

Returns the viewport's boundaries as a godot.Rect2.

@:native("GetViewportTransform")getViewportTransform():Transform2D

Returns this item's transform in relation to the viewport.

@:native("GetWorld2d")getWorld2d():World2D

Returns the godot.World2D where this item is in.

@:native("Hide")hide():Void

Hide the godot.CanvasItem if it's currently visible. This is equivalent to setting godot.CanvasItem.visible to false.

@:native("IsDrawBehindParentEnabled")isDrawBehindParentEnabled():Bool

@:native("IsLocalTransformNotificationEnabled")isLocalTransformNotificationEnabled():Bool

Returns true if local transform notifications are communicated to children.

@:native("IsSetAsToplevel")isSetAsToplevel():Bool

Returns true if the node is set as top-level. See godot.CanvasItem.setAsToplevel.

@:native("IsTransformNotificationEnabled")isTransformNotificationEnabled():Bool

Returns true if global transform notifications are communicated to children.

@:native("IsVisible")isVisible():Bool

@:native("IsVisibleInTree")isVisibleInTree():Bool

Returns true if the node is present in the godot.SceneTree, its godot.CanvasItem.visible property is true and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree.

@:native("MakeCanvasPositionLocal")makeCanvasPositionLocal(screenPoint:Vector2):Vector2

Assigns screen_point as this node's new local transform.

@:native("MakeInputLocal")makeInputLocal(event:InputEvent):InputEvent

Transformations issued by event's inputs are applied in local space instead of global space.

@:native("SetAsToplevel")setAsToplevel(enable:Bool):Void

If enable is true, this godot.CanvasItem will not inherit its transform from parent godot.CanvasItems. Its draw order will also be changed to make it draw on top of other godot.CanvasItems that are not set as top-level. The godot.CanvasItem will effectively act as if it was placed as a child of a bare godot.Node. See also godot.CanvasItem.isSetAsToplevel.

@:native("SetDrawBehindParent")setDrawBehindParent(enable:Bool):Void

@:native("SetLightMask")setLightMask(lightMask:Int):Void

@:native("SetMaterial")setMaterial(material:Material):Void

@:native("SetModulate")setModulate(modulate:Color):Void

@:native("SetNotifyLocalTransform")setNotifyLocalTransform(enable:Bool):Void

If enable is true, children will be updated with local transform data.

@:native("SetNotifyTransform")setNotifyTransform(enable:Bool):Void

If enable is true, children will be updated with global transform data.

@:native("SetSelfModulate")setSelfModulate(selfModulate:Color):Void

@:native("SetUseParentMaterial")setUseParentMaterial(enable:Bool):Void

@:native("SetVisible")setVisible(visible:Bool):Void

@:native("Show")show():Void

Show the godot.CanvasItem if it's currently hidden. This is equivalent to setting godot.CanvasItem.visible to true. For controls that inherit godot.Popup, the correct way to make them visible is to call one of the multiple popup*() functions instead.

@:native("Update")update():Void

Queue the godot.CanvasItem for update. godot.CanvasItem.notificationDraw will be called on idle time to request redraw.

Defined by Node

@:native("_EnterTree")_EnterTree():Void

Called when the node enters the godot.SceneTree (e.g. upon instancing, scene changing, or after calling godot.Node.addChild in a script). If the node has children, its godot.Node._EnterTree callback will be called first, and then that of the children.

Corresponds to the godot.Node.notificationEnterTree notification in godot.Object._Notification.

@:native("_ExitTree")_ExitTree():Void

Called when the node is about to leave the godot.SceneTree (e.g. upon freeing, scene changing, or after calling godot.Node.removeChild in a script). If the node has children, its godot.Node._ExitTree callback will be called last, after all its children have left the tree.

Corresponds to the godot.Node.notificationExitTree notification in godot.Object._Notification and signal tree_exiting. To get notified when the node has already left the active tree, connect to the tree_exited.

@:native("_GetConfigurationWarning")_GetConfigurationWarning():String

The string returned from this method is displayed as a warning in the Scene Dock if the script that overrides it is a tool script.

Returning an empty string produces no warning.

Call godot.Node.updateConfigurationWarning when the warning needs to be updated for this node.

@:native("_Input")_Input(event:InputEvent):Void

Called when there is an input event. The input event propagates up through the node tree until a node consumes it.

It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessInput.

To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled can be called.

For gameplay input, godot.Node._UnhandledInput and godot.Node._UnhandledKeyInput are usually a better fit as they allow the GUI to intercept the events first.

Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).

@:native("_PhysicsProcess")_PhysicsProcess(delta:Single):Void

Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the delta variable should be constant. delta is in seconds.

It is only called if physics processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setPhysicsProcess.

Corresponds to the godot.Node.notificationPhysicsProcess notification in godot.Object._Notification.

Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).

@:native("_Process")_Process(delta:Single):Void

Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the delta time since the previous frame is not constant. delta is in seconds.

It is only called if processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcess.

Corresponds to the godot.Node.notificationProcess notification in godot.Object._Notification.

Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).

@:native("_Ready")_Ready():Void

Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their godot.Node._Ready callbacks get triggered first, and the parent node will receive the ready notification afterwards.

Corresponds to the godot.Node.notificationReady notification in godot.Object._Notification. See also the onready keyword for variables.

Usually used for initialization. For even earlier initialization, may be used. See also godot.Node._EnterTree.

Note: godot.Node._Ready may be called only once for each node. After removing a node from the scene tree and adding again, _ready will not be called for the second time. This can be bypassed with requesting another call with godot.Node.requestReady, which may be called anywhere before adding the node again.

@:native("_UnhandledInput")_UnhandledInput(event:InputEvent):Void

Called when an godot.InputEvent hasn't been consumed by godot.Node._Input or any GUI. The input event propagates up through the node tree until a node consumes it.

It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessUnhandledInput.

To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled can be called.

For gameplay input, this and godot.Node._UnhandledKeyInput are usually a better fit than godot.Node._Input as they allow the GUI to intercept the events first.

Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).

@:native("_UnhandledKeyInput")_UnhandledKeyInput(event:InputEventKey):Void

Called when an godot.InputEventKey hasn't been consumed by godot.Node._Input or any GUI. The input event propagates up through the node tree until a node consumes it.

It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessUnhandledKeyInput.

To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled can be called.

For gameplay input, this and godot.Node._UnhandledInput are usually a better fit than godot.Node._Input as they allow the GUI to intercept the events first.

Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).

@:native("AddChild")addChild(node:Node, ?legibleUniqueName:Bool):Void

Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.

If legible_unique_name is true, the child node will have a human-readable name based on the name of the node being instanced instead of its type.

Note: If the child node already has a parent, the function will fail. Use godot.Node.removeChild first to remove the node from its current parent. For example:


if child_node.get_parent():
child_node.get_parent().remove_child(child_node)
add_child(child_node)

Note: If you want a child to be persisted to a godot.PackedScene, you must set godot.Node.owner in addition to calling godot.Node.addChild. This is typically relevant for [https://docs.godotengine.org/en/3.4/tutorials/misc/running_code_in_the_editor.html](tool scripts) and [https://docs.godotengine.org/en/3.4/tutorials/plugins/editor/index.html](editor plugins). If godot.Node.addChild is called without setting godot.Node.owner, the newly added godot.Node will not be visible in the scene tree, though it will be visible in the 2D/3D view.

@:native("AddChildBelowNode")addChildBelowNode(node:Node, childNode:Node, ?legibleUniqueName:Bool):Void

Adds child_node as a child. The child is placed below the given node in the list of children.

If legible_unique_name is true, the child node will have a human-readable name based on the name of the node being instanced instead of its type.

@:native("AddToGroup")addToGroup(group:String, ?persistent:Bool):Void

Adds the node to a group. Groups are helpers to name and organize a subset of nodes, for example "enemies" or "collectables". A node can be in any number of groups. Nodes can be assigned a group at any time, but will not be added until they are inside the scene tree (see godot.Node.isInsideTree). See notes in the description, and the group methods in godot.SceneTree.

The persistent option is used when packing node to godot.PackedScene and saving to file. Non-persistent groups aren't stored.

Note: For performance reasons, the order of node groups is not guaranteed. The order of node groups should not be relied upon as it can vary across project runs.

@:native("CanProcess")canProcess():Bool

Returns true if the node can process while the scene tree is paused (see godot.Node.pauseMode). Always returns true if the scene tree is not paused, and false if the node is not in the tree.

@:native("Duplicate")duplicate(?flags:Int):Node

Duplicates the node, returning a new node.

You can fine-tune the behavior using the flags (see godot.Node_DuplicateFlags).

Note: It will not work properly if the node contains a script with constructor arguments (i.e. needs to supply arguments to method). In that case, the node will be duplicated without a script.

@:native("FindNode")findNode(mask:String, ?recursive:Bool, ?owned:Bool):Node

Finds a descendant of this node whose name matches mask as in String.match (i.e. case-sensitive, but "*" matches zero or more characters and "?" matches any single character except "."). Returns null if no matching godot.Node is found.

Note: It does not match against the full path, just against individual node names.

If owned is true, this method only finds nodes whose owner is this node. This is especially important for scenes instantiated through a script, because those scenes don't have an owner.

Note: As this method walks through all the descendants of the node, it is the slowest way to get a reference to another node. Whenever possible, consider using godot.Node.getNode instead. To avoid using godot.Node.findNode too often, consider caching the node reference into a variable.

@:native("FindParent")findParent(mask:String):Node

Finds the first parent of the current node whose name matches mask as in String.match (i.e. case-sensitive, but "*" matches zero or more characters and "?" matches any single character except ".").

Note: It does not match against the full path, just against individual node names.

Note: As this method walks upwards in the scene tree, it can be slow in large, deeply nested scene trees. Whenever possible, consider using godot.Node.getNode instead. To avoid using godot.Node.findParent too often, consider caching the node reference into a variable.

@:native("GetChild")getChild(idx:Int):Node

Returns a child node by its index (see godot.Node.getChildCount). This method is often used for iterating all children of a node.

To access a child node via its name, use godot.Node.getNode.

@:native("GetChildCount")getChildCount():Int

Returns the number of child nodes.

@:native("GetChildOrNull")getChildOrNull<M0>(idx:Int):M0

@:native("GetChildren")getChildren():Array

Returns an array of references to node's children.

@:native("GetCustomMultiplayer")getCustomMultiplayer():MultiplayerAPI

@:native("GetFilename")getFilename():String

@:native("GetGroups")getGroups():Array

Returns an array listing the groups that the node is a member of.

Note: For performance reasons, the order of node groups is not guaranteed. The order of node groups should not be relied upon as it can vary across project runs.

Note: The engine uses some group names internally (all starting with an underscore). To avoid conflicts with internal groups, do not add custom groups whose name starts with an underscore. To exclude internal groups while looping over godot.Node.getGroups, use the following snippet:


# Stores the node's non-internal groups only (as an array of Strings).
var non_internal_groups = []
for group in get_groups():
if not group.begins_with("_"):
non_internal_groups.push_back(group)

@:native("GetIndex")getIndex():Int

Returns the node's index, i.e. its position among the siblings of its parent.

@:native("GetMultiplayer")getMultiplayer():MultiplayerAPI

@:native("GetName")getName():String

@:native("GetNetworkMaster")getNetworkMaster():Int

Returns the peer ID of the network master for this node. See godot.Node.setNetworkMaster.

@:native("GetNode")getNode(path:NodePath):Node

Fetches a node. The godot.NodePath can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a null instance is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error.

Note: Fetching absolute paths only works when the node is inside the scene tree (see godot.Node.isInsideTree).

Example: Assume your current node is Character and the following tree:


/root
/root/Character
/root/Character/Sword
/root/Character/Backpack/Dagger
/root/MyGame
/root/Swamp/Alligator
/root/Swamp/Mosquito
/root/Swamp/Goblin

Possible paths are:


get_node("Sword")
get_node("Backpack/Dagger")
get_node("../Swamp/Alligator")
get_node("/root/MyGame")

@:native("GetNodeAndResource")getNodeAndResource(path:NodePath):Array

Fetches a node and one of its resources as specified by the godot.NodePath's subname (e.g. Area2D/CollisionShape2D:shape). If several nested resources are specified in the godot.NodePath, the last one will be fetched.

The return value is an array of size 3: the first index points to the godot.Node (or null if not found), the second index points to the godot.Resource (or null if not found), and the third index is the remaining godot.NodePath, if any.

For example, assuming that Area2D/CollisionShape2D is a valid node and that its shape property has been assigned a godot.RectangleShape2D resource, one could have this kind of output:


print(get_node_and_resource("Area2D/CollisionShape2D")) # [[CollisionShape2D:1161], Null, ]
print(get_node_and_resource("Area2D/CollisionShape2D:shape")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], ]
print(get_node_and_resource("Area2D/CollisionShape2D:shape:extents")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], :extents]

@:native("GetNodeOrNull")getNodeOrNull(path:NodePath):Node

Similar to godot.Node.getNode, but does not log an error if path does not point to a valid godot.Node.

@:native("GetOwner")getOwner():Node

@:native("GetOwnerOrNull")getOwnerOrNull<M0>():M0

@:native("GetParent")getParent():Node

Returns the parent node of the current node, or a null instance if the node lacks a parent.

@:native("GetParentOrNull")getParentOrNull<M0>():M0

@:native("GetPath")getPath():NodePath

Returns the absolute path of the current node. This only works if the current node is inside the scene tree (see godot.Node.isInsideTree).

@:native("GetPathTo")getPathTo(node:Node):NodePath

Returns the relative godot.NodePath from this node to the specified node. Both nodes must be in the same scene or the function will fail.

@:native("GetPauseMode")getPauseMode():Node_PauseModeEnum

@:native("GetPhysicsProcessDeltaTime")getPhysicsProcessDeltaTime():Single

Returns the time elapsed (in seconds) since the last physics-bound frame (see godot.Node._PhysicsProcess). This is always a constant value in physics processing unless the frames per second is changed via godot.Engine.iterationsPerSecond.

@:native("GetPositionInParent")getPositionInParent():Int

Returns the node's order in the scene tree branch. For example, if called on the first child node the position is 0.

@:native("GetProcessDeltaTime")getProcessDeltaTime():Single

Returns the time elapsed (in seconds) since the last process callback. This value may vary from frame to frame.

@:native("GetProcessPriority")getProcessPriority():Int

@:native("GetSceneInstanceLoadPlaceholder")getSceneInstanceLoadPlaceholder():Bool

Returns true if this is an instance load placeholder. See godot.InstancePlaceholder.

@:native("GetTree")getTree():SceneTree

Returns the godot.SceneTree that contains this node.

@:native("GetViewport")getViewport():Viewport

Returns the node's godot.Viewport.

@:native("HasNode")hasNode(path:NodePath):Bool

Returns true if the node that the godot.NodePath points to exists.

@:native("HasNodeAndResource")hasNodeAndResource(path:NodePath):Bool

Returns true if the godot.NodePath points to a valid node and its subname points to a valid resource, e.g. Area2D/CollisionShape2D:shape. Properties with a non-godot.Resource type (e.g. nodes or primitive math types) are not considered resources.

@:native("IsAParentOf")isAParentOf(node:Node):Bool

Returns true if the given node is a direct or indirect child of the current node.

@:native("IsDisplayedFolded")isDisplayedFolded():Bool

Returns true if the node is folded (collapsed) in the Scene dock.

@:native("IsGreaterThan")isGreaterThan(node:Node):Bool

Returns true if the given node occurs later in the scene hierarchy than the current node.

@:native("IsInGroup")isInGroup(group:String):Bool

Returns true if this node is in the specified group. See notes in the description, and the group methods in godot.SceneTree.

@:native("IsInsideTree")isInsideTree():Bool

Returns true if this node is currently inside a godot.SceneTree.

@:native("IsNetworkMaster")isNetworkMaster():Bool

Returns true if the local system is the master of this node.

@:native("IsPhysicsProcessing")isPhysicsProcessing():Bool

Returns true if physics processing is enabled (see godot.Node.setPhysicsProcess).

@:native("IsPhysicsProcessingInternal")isPhysicsProcessingInternal():Bool

Returns true if internal physics processing is enabled (see godot.Node.setPhysicsProcessInternal).

@:native("IsProcessing")isProcessing():Bool

Returns true if processing is enabled (see godot.Node.setProcess).

@:native("IsProcessingInput")isProcessingInput():Bool

Returns true if the node is processing input (see godot.Node.setProcessInput).

@:native("IsProcessingInternal")isProcessingInternal():Bool

Returns true if internal processing is enabled (see godot.Node.setProcessInternal).

@:native("IsProcessingUnhandledInput")isProcessingUnhandledInput():Bool

Returns true if the node is processing unhandled input (see godot.Node.setProcessUnhandledInput).

@:native("IsProcessingUnhandledKeyInput")isProcessingUnhandledKeyInput():Bool

Returns true if the node is processing unhandled key input (see godot.Node.setProcessUnhandledKeyInput).

@:native("MoveChild")moveChild(childNode:Node, toPosition:Int):Void

Moves a child node to a different position (order) among the other children. Since calls, signals, etc are performed by tree order, changing the order of children nodes may be useful.

@:native("PrintStrayNodes")printStrayNodes():Void

Prints all stray nodes (nodes outside the godot.SceneTree). Used for debugging. Works only in debug builds.

@:native("PrintTree")printTree():Void

Prints the tree to stdout. Used mainly for debugging purposes. This version displays the path relative to the current node, and is good for copy/pasting into the godot.Node.getNode function.

Example output:


TheGame
TheGame/Menu
TheGame/Menu/Label
TheGame/Menu/Camera2D
TheGame/SplashScreen
TheGame/SplashScreen/Camera2D

@:native("PrintTreePretty")printTreePretty():Void

Similar to godot.Node.printTree, this prints the tree to stdout. This version displays a more graphical representation similar to what is displayed in the scene inspector. It is useful for inspecting larger trees.

Example output:


┖╴TheGame
┠╴Menu
┃  ┠╴Label
┃  ┖╴Camera2D
┖╴SplashScreen
┖╴Camera2D

@:native("PropagateCall")propagateCall(method:String, ?args:Array, ?parentFirst:Bool):Void

Calls the given method (if present) with the arguments given in args on this node and recursively on all its children. If the parent_first argument is true, the method will be called on the current node first, then on all its children. If parent_first is false, the children will be called first.

Parameters:

args

If the parameter is null, then the default value is new Godot.Collections.Array { }

@:native("PropagateNotification")propagateNotification(what:Int):Void

Notifies the current node and all its children recursively by calling godot.Object.notification on all of them.

@:native("QueueFree")queueFree():Void

Queues a node for deletion at the end of the current frame. When deleted, all of its child nodes will be deleted as well. This method ensures it's safe to delete the node, contrary to godot.Object.free. Use godot.Object.isQueuedForDeletion to check whether a node will be deleted at the end of the frame.

Important: If you have a variable pointing to a node, it will not be assigned to null once the node is freed. Instead, it will point to a previously freed instance and you should validate it with @GDScript.is_instance_valid before attempting to call its methods or access its properties.

@:native("Raise")raise():Void

Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs (godot.Control nodes), because their order of drawing depends on their order in the tree. The top Node is drawn first, then any siblings below the top Node in the hierarchy are successively drawn on top of it. After using raise, a Control will be drawn on top of its siblings.

@:native("RemoveAndSkip")removeAndSkip():Void

Removes a node and sets all its children as children of the parent node (if it exists). All event subscriptions that pass by the removed node will be unsubscribed.

@:native("RemoveChild")removeChild(node:Node):Void

Removes a child node. The node is NOT deleted and must be deleted manually.

Note: This function may set the godot.Node.owner of the removed Node (or its descendants) to be null, if that godot.Node.owner is no longer a parent or ancestor.

@:native("RemoveFromGroup")removeFromGroup(group:String):Void

Removes a node from a group. See notes in the description, and the group methods in godot.SceneTree.

@:native("ReplaceBy")replaceBy(node:Node, ?keepData:Bool):Void

Replaces a node in a scene by the given one. Subscriptions that pass through this node will be lost.

Note that the replaced node is not automatically freed, so you either need to keep it in a variable for later use or free it using godot.Object.free.

@:native("RequestReady")requestReady():Void

Requests that _ready be called again. Note that the method won't be called immediately, but is scheduled for when the node is added to the scene tree again (see godot.Node._Ready). _ready is called only for the node which requested it, which means that you need to request ready for each child if you want them to call _ready too (in which case, _ready will be called in the same order as it would normally).

@:native("Rpc")rpc(method:String, args:HaxeArray<Dynamic>):Dynamic

Sends a remote procedure call request for the given method to peers on the network (and locally), optionally sending all additional arguments as arguments to the method called by the RPC. The call request will only be received by nodes with the same godot.NodePath, including the exact same node name. Behaviour depends on the RPC configuration for the given method, see godot.Node.rpcConfig. Methods are not exposed to RPCs by default. See also godot.Node.rset and godot.Node.rsetConfig for properties. Returns null.

Note: You can only safely use RPCs on clients after you received the connected_to_server signal from the godot.SceneTree. You also need to keep track of the connection state, either by the godot.SceneTree signals like server_disconnected or by checking SceneTree.network_peer.get_connection_status() == CONNECTION_CONNECTED.

@:native("RpcConfig")rpcConfig(method:String, mode:MultiplayerAPI_RPCMode):Void

Changes the RPC mode for the given method to the given mode. See godot.MultiplayerAPI_RPCMode. An alternative is annotating methods and properties with the corresponding keywords (remote, master, puppet, remotesync, mastersync, puppetsync). By default, methods are not exposed to networking (and RPCs). See also godot.Node.rset and godot.Node.rsetConfig for properties.

@:native("RpcId")rpcId(peerId:Int, method:String, args:HaxeArray<Dynamic>):Dynamic

Sends a godot.Node.rpc to a specific peer identified by peer_id (see godot.NetworkedMultiplayerPeer.setTargetPeer). Returns null.

@:native("RpcUnreliable")rpcUnreliable(method:String, args:HaxeArray<Dynamic>):Dynamic

Sends a godot.Node.rpc using an unreliable protocol. Returns null.

@:native("RpcUnreliableId")rpcUnreliableId(peerId:Int, method:String, args:HaxeArray<Dynamic>):Dynamic

Sends a godot.Node.rpc to a specific peer identified by peer_id using an unreliable protocol (see godot.NetworkedMultiplayerPeer.setTargetPeer). Returns null.

@:native("Rset")rset(property:String, value:Dynamic):Void

Remotely changes a property's value on other peers (and locally). Behaviour depends on the RPC configuration for the given property, see godot.Node.rsetConfig. See also godot.Node.rpc for RPCs for methods, most information applies to this method as well.

@:native("RsetConfig")rsetConfig(property:String, mode:MultiplayerAPI_RPCMode):Void

Changes the RPC mode for the given property to the given mode. See godot.MultiplayerAPI_RPCMode. An alternative is annotating methods and properties with the corresponding keywords (remote, master, puppet, remotesync, mastersync, puppetsync). By default, properties are not exposed to networking (and RPCs). See also godot.Node.rpc and godot.Node.rpcConfig for methods.

@:native("RsetId")rsetId(peerId:Int, property:String, value:Dynamic):Void

Remotely changes the property's value on a specific peer identified by peer_id (see godot.NetworkedMultiplayerPeer.setTargetPeer).

@:native("RsetUnreliable")rsetUnreliable(property:String, value:Dynamic):Void

Remotely changes the property's value on other peers (and locally) using an unreliable protocol.

@:native("RsetUnreliableId")rsetUnreliableId(peerId:Int, property:String, value:Dynamic):Void

Remotely changes property's value on a specific peer identified by peer_id using an unreliable protocol (see godot.NetworkedMultiplayerPeer.setTargetPeer).

@:native("SetCustomMultiplayer")setCustomMultiplayer(api:MultiplayerAPI):Void

@:native("SetDisplayFolded")setDisplayFolded(fold:Bool):Void

Sets the folded state of the node in the Scene dock.

@:native("SetFilename")setFilename(filename:String):Void

@:native("SetName")setName(name:String):Void

@:native("SetNetworkMaster")setNetworkMaster(id:Int, ?recursive:Bool):Void

Sets the node's network master to the peer with the given peer ID. The network master is the peer that has authority over the node on the network. Useful in conjunction with the master and puppet keywords. Inherited from the parent node by default, which ultimately defaults to peer ID 1 (the server). If recursive, the given peer is recursively set as the master for all children of this node.

@:native("SetOwner")setOwner(owner:Node):Void

@:native("SetPauseMode")setPauseMode(mode:Node_PauseModeEnum):Void

@:native("SetPhysicsProcess")setPhysicsProcess(enable:Bool):Void

Enables or disables physics (i.e. fixed framerate) processing. When a node is being processed, it will receive a godot.Node.notificationPhysicsProcess at a fixed (usually 60 FPS, see godot.Engine.iterationsPerSecond to change) interval (and the godot.Node._PhysicsProcess callback will be called if exists). Enabled automatically if godot.Node._PhysicsProcess is overridden. Any calls to this before godot.Node._Ready will be ignored.

@:native("SetPhysicsProcessInternal")setPhysicsProcessInternal(enable:Bool):Void

Enables or disables internal physics for this node. Internal physics processing happens in isolation from the normal godot.Node._PhysicsProcess calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or physics processing is disabled for scripting (godot.Node.setPhysicsProcess). Only useful for advanced uses to manipulate built-in nodes' behavior.

Warning: Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported.

@:native("SetProcess")setProcess(enable:Bool):Void

Enables or disables processing. When a node is being processed, it will receive a godot.Node.notificationProcess on every drawn frame (and the godot.Node._Process callback will be called if exists). Enabled automatically if godot.Node._Process is overridden. Any calls to this before godot.Node._Ready will be ignored.

@:native("SetProcessInput")setProcessInput(enable:Bool):Void

Enables or disables input processing. This is not required for GUI controls! Enabled automatically if godot.Node._Input is overridden. Any calls to this before godot.Node._Ready will be ignored.

@:native("SetProcessInternal")setProcessInternal(enable:Bool):Void

Enables or disabled internal processing for this node. Internal processing happens in isolation from the normal godot.Node._Process calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or processing is disabled for scripting (godot.Node.setProcess). Only useful for advanced uses to manipulate built-in nodes' behavior.

Warning: Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported.

@:native("SetProcessPriority")setProcessPriority(priority:Int):Void

@:native("SetProcessUnhandledInput")setProcessUnhandledInput(enable:Bool):Void

Enables unhandled input processing. This is not required for GUI controls! It enables the node to receive all input that was not previously handled (usually by a godot.Control). Enabled automatically if godot.Node._UnhandledInput is overridden. Any calls to this before godot.Node._Ready will be ignored.

@:native("SetProcessUnhandledKeyInput")setProcessUnhandledKeyInput(enable:Bool):Void

Enables unhandled key input processing. Enabled automatically if godot.Node._UnhandledKeyInput is overridden. Any calls to this before godot.Node._Ready will be ignored.

@:native("SetSceneInstanceLoadPlaceholder")setSceneInstanceLoadPlaceholder(loadPlaceholder:Bool):Void

Sets whether this is an instance load placeholder. See godot.InstancePlaceholder.

@:native("UpdateConfigurationWarning")updateConfigurationWarning():Void

Updates the warning displayed for this node in the Scene Dock.

Use godot.Node._GetConfigurationWarning to setup the warning message to display.

Defined by Object

@:native("_Get")_Get(property:String):Dynamic

Virtual method which can be overridden to customize the return value of godot.Object.get.

Returns the given property. Returns null if the property does not exist.

@:native("_GetPropertyList")_GetPropertyList():Array

Virtual method which can be overridden to customize the return value of godot.Object.getPropertyList.

Returns the object's property list as an godot.Collections_Array of dictionaries.

Each property's godot.Collections_Dictionary must contain at least name: String and type: int (see godot.Variant_Type) entries. Optionally, it can also include hint: int (see godot.PropertyHint), hint_string: String, and usage: int (see godot.PropertyUsageFlags).

@:native("_Notification")_Notification(what:Int):Void

Called whenever the object receives a notification, which is identified in what by a constant. The base godot.Object has two constants godot.Object.notificationPostinitialize and godot.Object.notificationPredelete, but subclasses such as godot.Node define a lot more notifications which are also received by this method.

@:native("_Set")_Set(property:String, value:Dynamic):Bool

Virtual method which can be overridden to customize the return value of godot.Object.set.

Sets a property. Returns true if the property exists.

@:native("AddUserSignal")addUserSignal(signal:String, ?arguments:Array):Void

Adds a user-defined signal. Arguments are optional, but can be added as an godot.Collections_Array of dictionaries, each containing name: String and type: int (see godot.Variant_Type) entries.

Parameters:

arguments

If the parameter is null, then the default value is new Godot.Collections.Array { }

@:native("Call")call(method:String, args:HaxeArray<Dynamic>):Dynamic

Calls the method on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:


call("set", "position", Vector2(42.0, 0.0))

Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).

@:native("CallDeferred")callDeferred(method:String, args:HaxeArray<Dynamic>):Void

Calls the method on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:


call_deferred("set", "position", Vector2(42.0, 0.0))

Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).

@:native("Callv")callv(method:String, argArray:Array):Dynamic

Calls the method on the object and returns the result. Contrarily to godot.Object.call, this method does not support a variable number of arguments but expects all parameters to be via a single godot.Collections_Array.


callv("set", [ "position", Vector2(42.0, 0.0) ])

@:native("CanTranslateMessages")canTranslateMessages():Bool

Returns true if the object can translate strings. See godot.Object.setMessageTranslation and godot.Object.tr.

@:native("Connect")connect(signal:String, target:Object, method:String, ?binds:Array, ?flags:UInt):Error

Connects a signal to a method on a target object. Pass optional binds to the call as an godot.Collections_Array of parameters. These parameters will be passed to the method after any parameter used in the call to godot.Object.emitSignal. Use flags to set deferred or one-shot connections. See godot.Object_ConnectFlags constants.

A signal can only be connected once to a method. It will print an error if already connected, unless the signal was connected with godot.Object_ConnectFlags.referenceCounted. To avoid this, first, use godot.Object.isConnected to check for existing connections.

If the target is destroyed in the game's lifecycle, the connection will be lost.

Examples:


connect("pressed", self, "_on_Button_pressed") # BaseButton signal
connect("text_entered", self, "_on_LineEdit_text_entered") # LineEdit signal
connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # User-defined signal

An example of the relationship between binds passed to godot.Object.connect and parameters used when calling godot.Object.emitSignal:


connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # weapon_type and damage are passed last
emit_signal("hit", "Dark lord", 5) # "Dark lord" and 5 are passed first
func _on_Player_hit(hit_by, level, weapon_type, damage):
print("Hit by %s (lvl %d) with weapon %s for %d damage" % [hit_by, level, weapon_type, damage])

Parameters:

binds

If the parameter is null, then the default value is new Godot.Collections.Array { }

@:native("Disconnect")disconnect(signal:String, target:Object, method:String):Void

Disconnects a signal from a method on the given target.

If you try to disconnect a connection that does not exist, the method will print an error. Use godot.Object.isConnected to ensure that the connection exists.

@:native("Dispose")dispose():Void

@:native("Dispose")@:protectedDispose(disposing:Bool):Void

Disposes of this godot.Object.

@:native("EmitSignal")emitSignal(signal:String, args:HaxeArray<Dynamic>):Void

Emits the given signal. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:


emit_signal("hit", weapon_type, damage)
emit_signal("game_over")

@:native("Free")free():Void

Deletes the object from memory immediately. For godot.Nodes, you may want to use godot.Node.queueFree to queue the node for safe deletion at the end of the current frame.

Important: If you have a variable pointing to an object, it will not be assigned to null once the object is freed. Instead, it will point to a previously freed instance and you should validate it with @GDScript.is_instance_valid before attempting to call its methods or access its properties.

@:native("Get")get(property:String):Dynamic

Returns the Variant value of the given property. If the property doesn't exist, this will return null.

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

@:native("GetClass")getClass():String

Returns the object's class as a String. See also godot.Object.isClass.

Note: godot.Object.getClass does not take class_name declarations into account. If the object has a class_name defined, the base class name will be returned instead.

@:native("GetIncomingConnections")getIncomingConnections():Array

Returns an godot.Collections_Array of dictionaries with information about signals that are connected to the object.

Each godot.Collections_Dictionary contains three String entries:

  • source is a reference to the signal emitter.

  • signal_name is the name of the connected signal.

  • method_name is the name of the method to which the signal is connected.

@:native("GetIndexed")getIndexed(property:NodePath):Dynamic

Gets the object's property indexed by the given godot.NodePath. The node path should be relative to the current object and can use the colon character (:) to access nested properties. Examples: "position:x" or "material:next_pass:blend_mode".

Note: Even though the method takes godot.NodePath argument, it doesn't support actual paths to godot.Nodes in the scene tree, only colon-separated sub-property paths. For the purpose of nodes, use godot.Node.getNodeAndResource instead.

@:native("GetInstanceId")getInstanceId():UInt64

Returns the object's unique instance ID.

This ID can be saved in godot.EncodedObjectAsID, and can be used to retrieve the object instance with @GDScript.instance_from_id.

@:native("GetMeta")getMeta(name:String):Dynamic

Returns the object's metadata entry for the given name.

inlinegetMetaList():Array<String>

Returns the object's metadata as a String.

@:native("GetMethodList")getMethodList():Array

Returns the object's methods and their signatures as an godot.Collections_Array.

@:native("GetPropertyList")getPropertyList():Array

Returns the object's property list as an godot.Collections_Array of dictionaries.

Each property's godot.Collections_Dictionary contain at least name: String and type: int (see godot.Variant_Type) entries. Optionally, it can also include hint: int (see godot.PropertyHint), hint_string: String, and usage: int (see godot.PropertyUsageFlags).

@:native("GetScript")getScript():Reference

Returns the object's godot.Script instance, or null if none is assigned.

@:native("GetSignalConnectionList")getSignalConnectionList(signal:String):Array

Returns an godot.Collections_Array of connections for the given signal.

@:native("GetSignalList")getSignalList():Array

Returns the list of signals as an godot.Collections_Array of dictionaries.

@:native("HasMeta")hasMeta(name:String):Bool

Returns true if a metadata entry is found with the given name.

@:native("HasMethod")hasMethod(method:String):Bool

Returns true if the object contains the given method.

@:native("HasSignal")hasSignal(signal:String):Bool

Returns true if the given signal exists.

@:native("HasUserSignal")hasUserSignal(signal:String):Bool

Returns true if the given user-defined signal exists. Only signals added using godot.Object.addUserSignal are taken into account.

@:native("IsBlockingSignals")isBlockingSignals():Bool

Returns true if signal emission blocking is enabled.

@:native("IsClass")isClass(class_:String):Bool

Returns true if the object inherits from the given class. See also godot.Object.getClass.

Note: godot.Object.isClass does not take class_name declarations into account. If the object has a class_name defined, godot.Object.isClass will return false for that name.

@:native("IsConnected")isConnected(signal:String, target:Object, method:String):Bool

Returns true if a connection exists for a given signal, target, and method.

@:native("IsQueuedForDeletion")isQueuedForDeletion():Bool

Returns true if the godot.Node.queueFree method was called for the object.

@:native("Notification")notification(what:Int, ?reversed:Bool):Void

Send a given notification to the object, which will also trigger a call to the godot.Object._Notification method of all classes that the object inherits from.

If reversed is true, godot.Object._Notification is called first on the object's own class, and then up to its successive parent classes. If reversed is false, godot.Object._Notification is called first on the highest ancestor (godot.Object itself), and then down to its successive inheriting classes.

@:native("PropertyListChangedNotify")propertyListChangedNotify():Void

Notify the editor that the property list has changed, so that editor plugins can take the new values into account. Does nothing on export builds.

@:native("RemoveMeta")removeMeta(name:String):Void

Removes a given entry from the object's metadata. See also godot.Object.setMeta.

@:native("Set")set(property:String, value:Dynamic):Void

Assigns a new value to the given property. If the property does not exist or the given value's type doesn't match, nothing will happen.

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

@:native("SetBlockSignals")setBlockSignals(enable:Bool):Void

If set to true, signal emission is blocked.

@:native("SetDeferred")setDeferred(property:String, value:Dynamic):Void

Assigns a new value to the given property, after the current frame's physics step. This is equivalent to calling godot.Object.set via godot.Object.callDeferred, i.e. call_deferred("set", property, value).

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

@:native("SetIndexed")setIndexed(property:NodePath, value:Dynamic):Void

Assigns a new value to the property identified by the godot.NodePath. The node path should be relative to the current object and can use the colon character (:) to access nested properties. Example:


set_indexed("position", Vector2(42, 0))
set_indexed("position:y", -10)
print(position) # (42, -10)

@:native("SetMessageTranslation")setMessageTranslation(enable:Bool):Void

Defines whether the object can translate strings (with calls to godot.Object.tr). Enabled by default.

@:native("SetMeta")setMeta(name:String, value:Dynamic):Void

Adds, changes or removes a given entry in the object's metadata. Metadata are serialized and can take any Variant value.

To remove a given entry from the object's metadata, use godot.Object.removeMeta. Metadata is also removed if its value is set to null. This means you can also use set_meta("name", null) to remove metadata for "name".

@:native("SetScript")setScript(script:Reference):Void

Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality.

If the object already had a script, the previous script instance will be freed and its variables and state will be lost. The new script's method will be called.

@:native("ToSignal")toSignal(source:Object, signal:String):SignalAwaiter

Returns a new godot.SignalAwaiter awaiter configured to complete when the instance source emits the signal specified by the signal parameter.

Parameters:

source

The instance the awaiter will be listening to.

signal

The signal the awaiter will be waiting for. This sample prints a message once every frame up to 100 times.

public override void _Ready()
{
for (int i = 0; i &lt; 100; i++)
{
await ToSignal(GetTree(), "idle_frame");
GD.Print($"Frame {i}");
}
}

Returns:

A godot.SignalAwaiter that completes when source emits the signal.

@:native("ToString")toString():String

Converts this godot.Object to a string.

Returns:

A string representation of this object.

@:native("Tr")tr(message:String):String

Translates a message using translation catalogs configured in the Project Settings.

Only works if message translation is enabled (which it is by default), otherwise it returns the message unchanged. See godot.Object.setMessageTranslation.