Node2D

    Inherited By: , AudioStreamPlayer2D, , Bone2D, , Camera2D, , CollisionObject2D, , CollisionShape2D, , Light2D, , Line2D, , Navigation2D, , ParallaxLayer, , Path2D, , Polygon2D, , RayCast2D, , Skeleton2D, , TileMap, , VisibilityNotifier2D,

    Category: Core

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

    Properties

    voidapply_scale ( ratio )
    float ( Vector2 point ) const
    get_relative_transform_to_parent ( parent ) const
    voidglobal_translate ( offset )
    voidlook_at ( point )
    voidmove_local_x ( delta, bool scaled=false )
    void ( float delta, scaled=false )
    voidrotate ( radians )
    Vector2 ( Vector2 local_point ) const
    to_local ( global_point ) const
    voidtranslate ( offset )

    Description

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

    Property Descriptions

    • global_position
    Setterset_global_position(value)
    Getterget_global_position()

    Global position.


    Setterset_global_rotation(value)
    Getterget_global_rotation()

    Global rotation in radians.


    • float global_rotation_degrees

    Global rotation in degrees.


    • global_scale
    Setterset_global_scale(value)
    Getterget_global_scale()

    Global scale.


    Setterset_global_transform(value)
    Getterget_global_transform()

    • position
    Setterset_position(value)
    Getterget_position()

    Position, relative to the node’s parent.


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


    • rotation_degrees
    Setterset_rotation_degrees(value)
    Getterget_rotation_degrees()

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


    Setterset_scale(value)
    Getterget_scale()

    The node’s scale. Unscaled value:


    • transform
    Setterset_transform(value)
    Getterget_transform()

    Local Transform2D.


    • z_as_relative

    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.


    Setterset_z_index(value)
    Getterget_z_index()

    Z-index. Controls the order in which the nodes render. A node with a higher Z-index will display in front of others.

    • void apply_scale ( Vector2 ratio )

    Multiplies the current scale by the ‘ratio’ vector.


    • get_angle_to ( Vector2 point ) const

    • get_relative_transform_to_parent ( Node parent ) const

    Returns the relative to this node’s parent.


    • void global_translate ( Vector2 offset )

    Adds the ‘offset’ vector to the node’s global position.


    • void look_at ( point )

    Rotates the node so it points towards the ‘point’.


    • void move_local_x ( float delta, scaled=false )

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


    • void move_local_y ( delta, bool scaled=false )

    Applies a local translation on the node’s Y axis based on the ’s delta. If is false, normalizes the movement.


    • void rotate ( float radians )

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


    • to_global ( Vector2 local_point ) const

    Converts a local point’s coordinates to global coordinates.


    Converts a global point’s coordinates to local coordinates.


    • void translate ( offset )