Node2D¶
Inherits: CanvasItem < Node < Object
Inherited By: RemoteTransform2D, Joint2D, ParticleAttractor2D, CollisionObject2D, VisibilityNotifier2D, TileMap, Navigation2D, CollisionPolygon2D, TouchScreenButton, Particles2D, AnimatedSprite, Light2D, SoundPlayer2D, ViewportSprite, Path2D, Sprite, RayCast2D, CollisionShape2D, NavigationPolygonInstance, PathFollow2D, ParallaxLayer, Polygon2D, Position2D, LightOccluder2D, BackBufferCopy, CanvasModulate, YSort, Camera2D
Category: Core
Brief Description¶
Base node for 2D system.
Member Functions¶
void | edit_set_pivot ( Vector2 pivot ) |
float | get_angle_to ( Vector2 point ) const |
Vector2 | get_global_pos ( ) const |
Vector2 | get_pos ( ) const |
Matrix32 | get_relative_transform_to_parent ( Object parent ) const |
float | get_rot ( ) const |
float | get_rotd ( ) const |
Vector2 | get_scale ( ) const |
int | get_z ( ) const |
void | global_translate ( Vector2 offset ) |
bool | is_z_relative ( ) const |
void | look_at ( Vector2 point ) |
void | move_local_x ( float delta, bool scaled=false ) |
void | move_local_y ( float delta, bool scaled=false ) |
void | rotate ( float radians ) |
void | scale ( Vector2 ratio ) |
void | set_global_pos ( Vector2 pos ) |
void | set_global_transform ( Matrix32 xform ) |
void | set_pos ( Vector2 pos ) |
void | set_rot ( float radians ) |
void | set_rotd ( float degrees ) |
void | set_scale ( Vector2 scale ) |
void | set_transform ( Matrix32 xform ) |
void | set_z ( int z ) |
void | set_z_as_relative ( bool enable ) |
void | translate ( Vector2 offset ) |
Description¶
Base node for 2D system. Node2D contains a position, rotation and scale, which is used to position and animate. It can alternatively be used with a custom 2D transform (Matrix32). A tree of Node2Ds allows complex hierarchies for animation and positioning.
Member Function Description¶
- void edit_set_pivot ( Vector2 pivot )
Set the pivot position of the 2D node to ‘pivot’ value. This method is implemented only in some nodes that inherit Node2D.
Return the rotation angle in radians needed for the 2d node to point at ‘point’ position.
- Vector2 get_global_pos ( ) const
Return the global position of the 2D node.
- Vector2 get_pos ( ) const
Return the position of the 2D node.
Return the transform Matrix32 calculated relatively to the parent of this 2D node.
- float get_rot ( ) const
Return the rotation of the 2D node.
- float get_rotd ( ) const
- Vector2 get_scale ( ) const
Return the scale of the 2D node.
- int get_z ( ) const
Return the Z-index of the 2D node.
- void global_translate ( Vector2 offset )
Apply a global translation of ‘offset’ to the 2D node, starting from its current global position.
- bool is_z_relative ( ) const
Return true if the Z-index value of this 2D node is relative to its parent’s. Else, return false.
- void look_at ( Vector2 point )
Rotate the 2d node so it points at ‘point’ position.
Apply a local translation on X axis to the 2D node according to the ‘delta’ of the process. If ‘scaled’ is false, the movement is normalized.
Apply a local translation on Y axis to the 2D node according to the ‘delta’ of the process. If ‘scaled’ is false, the movement is normalized.
- void rotate ( float radians )
Apply a ‘radians’ rotation to the 2D node, starting from its current rotation.
- void scale ( Vector2 ratio )
Apply the ‘ratio’ scale to the 2D node, according to its current scale value.
- void set_global_pos ( Vector2 pos )
Set the global position of the 2D node to ‘pos’.
- void set_global_transform ( Matrix32 xform )
Set the global transform Matrix32 of the 2D node.
- void set_pos ( Vector2 pos )
Set the position of the 2D node.
- void set_rot ( float radians )
Set the rotation of the 2D node.
- void set_rotd ( float degrees )
Set the rotation of the 2D node.
- void set_scale ( Vector2 scale )
Set the scale of the 2D node.
- void set_transform ( Matrix32 xform )
Set the local transform Matrix32 of the 2D node.
- void set_z ( int z )
Set the Z-index value of the 2D node.
- void set_z_as_relative ( bool enable )
Set the Z-index value as relative to the parent node of this 2D node. Thus, if this 2D node’s Z-index value is 2 and its parent’s effective Z-index is 3, then the effective Z-index value of this 2D node would be 3 + 2 = 5.
- void translate ( Vector2 offset )
Apply a local translation of ‘offset’ to the 2D node, starting from its current local position.