class Godot::Object

Overview

Base class for all Godot engine objects and extension classes. Provides identity, lifecycle dispatch hooks, and signal emission functionality.

Direct Known Subclasses

Defined in:

libgodot/generated/classes/classes_part1.cr
libgodot/object.cr
libgodot/variant.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(pointer : Pointer(Void) = Pointer(Void).null) #

[View source]

Class Method Detail

def self._godot_has_virtual_method(method_name : String) : Bool #

Checks if this object class overrides a generic virtual method.


[View source]
def self.is_instance_id_valid(id : Int | UInt64) : Bool #

Checks if a 64-bit instance ID is currently valid in Godot's ObjectDB


[View source]

Instance Method Detail

def ==(other : Godot::Object) : Bool #

Value equality based on Godot engine identity (instance ID or underlying pointer)


[View source]
def ==(other : Nil) : Bool #

[View source]
def _godot_call_tool_button(button_name : String) : Void #

Dispatches inspector tool button clicks on this object.


[View source]
def _godot_call_virtual(method_name : String, delta : Float64) : Void #

Virtual method and property dispatch hooks overridden by class registration macros. Delta timestep is received with 64-bit precision (Float64).


[View source]
def _godot_call_virtual_with_data(method_name : String, args : Pointer(Pointer(Void)), ret : Pointer(Void)) : Void #

Dispatches generic virtual methods with raw arguments and return buffer.


[View source]
def _godot_get_property(prop_name : String, ret_ptr : Pointer(Void)) : Void #

Invoked by the GDExtension bridge when retrieving an exposed @export property.


[View source]
def _godot_set_property(prop_name : String, val_ptr : Pointer(Void)) : Void #

Invoked by the GDExtension bridge when setting an exposed @export property.


[View source]
def add_user_signal(signal : String, arguments : Godot::Array) : Void #

[View source]
def alive? : Bool #

Returns true if this object instance has a valid engine pointer and is alive in Godot's ObjectDB


[View source]
def await_signal(signal_name : String, timeout_sec : Float64 | Nil = nil) : Array(Variant) #

Cooperatively awaits a signal emitted on this object.


[View source]
def call(method : String, *args) : Pointer(Void) #

Calls the named method on the object with variable arguments.


[View source]
def call_bool(method : String, *args) : Bool #

Calls the named method and returns the result as Bool


[View source]
def call_deferred(method : String, *args) : Pointer(Void) #

Calls the named method on the object during idle time.


[View source]
def call_f64(method : String, *args) : Float64 #

Calls the named method and returns the result as Float64


[View source]
def call_i64(method : String, *args) : Int64 #

Calls the named method and returns the result as Int64


[View source]
def call_obj(method : String, *args) : Node | Nil #

Calls the named method and returns an Object/Node (or nil if null)


[View source]
def call_obj_as(type : T.class, method : String, *args) : T | Nil forall T #

Calls the named method and returns the result cast to T (or nil if null)


[View source]
def call_str(method : String, *args) : String #

Calls the named method and returns the result as String


[View source]
def callv(method : String, arg_array : Godot::Array) : Pointer(Void) #

[View source]
def can_translate_messages : Bool #

[View source]
def cancel_free : Void #

[View source]
def check_alive! : Void #

Validates that the underlying engine object is still alive before executing bridge calls. Raises DisposedObjectError if the object was destroyed by GDScript, engine, or Crystal.


[View source]
def connect(signal_name : String, flags : Godot::ConnectFlags = ::Godot::ConnectFlags::None, callback : Proc(Array(Variant), Void) | Nil = nil) : SignalSubscription #

Connects a callback proc to the named signal.


[View source]
def connect(signal_name : String, flags : Godot::ConnectFlags = ::Godot::ConnectFlags::None, &block : Array(Variant) -> Void) : SignalSubscription #

Connects a callback block accepting Array(Variant) to the named signal.


[View source]
def connect(signal_name : String, listener_target : Godot::Object, method_name : Symbol, flags : Godot::ConnectFlags = ::Godot::ConnectFlags::None) : SignalSubscription #

Connects the named signal to a method call on a listener target by symbol name.


[View source]
def connect(signal : String, callable : Pointer(Void), flags : Int64) : Int64 #

[View source]
def connect_one_shot(signal_name : String, &block : Array(Variant) -> Void) : SignalSubscription #

Connects a one-shot callback block to the named signal (backwards compatibility).


[View source]
def destroy : Void #

Destroys this Object in the Godot engine and invalidates the Crystal pointer.


[View source]
def destroyed? : Bool #

[View source]
def disconnect(signal : String, callable : Pointer(Void)) : Void #

[View source]
def disconnect(signal_name : String) : Void #

Disconnects all signal subscriptions for the named signal on this object.


[View source]
def editor_hint? : Bool #

Returns true if running inside the Godot Editor


[View source]
def emit_signal(name : String) : Void #

Emits a parameterless signal on this Godot object.


[View source]
def emit_signal(name : String, *args) : Void #

Emits a signal with variable arguments on this Godot object.


[View source]
def free : Void #

Destroys this Object in the Godot engine (alias to #destroy).


[View source]
def get(property : String) : Pointer(Void) #

[View source]
def get_class : String #

[View source]
def get_incoming_connections : Godot::Array #

[View source]
def get_indexed(property_path : NodePath) : Pointer(Void) #

[View source]
def get_instance_id : Int64 #

[View source]
def get_meta(name : String, default : Pointer(Void)) : Pointer(Void) #

[View source]
def get_meta_list : Godot::Array #

[View source]
def get_method_argument_count(method : String) : Int64 #

[View source]
def get_method_list : Godot::Array #

[View source]
def get_property_list : Godot::Array #

[View source]
def get_script : Pointer(Void) #

[View source]
def get_signal_connection_list(signal : String) : Godot::Array #

[View source]
def get_signal_list : Godot::Array #

[View source]
def get_translation_domain : String #

[View source]
def has_connections(signal : String) : Bool #

[View source]
def has_meta(name : String) : Bool #

[View source]
def has_method(method : String) : Bool #

[View source]
def has_signal(signal : String) : Bool #

[View source]
def has_signal?(signal_name : String) : Bool #

Returns true if this object or its registered class defines the given signal.


[View source]
def has_user_signal(signal : String) : Bool #

[View source]
def hash(hasher) #

Hashing based on engine instance ID for use in Sets and Hash keys


[View source]
def if_alive : self | Nil #

Convenient nil-coalescing helper: returns self if alive, otherwise nil


[View source]
def instance_id : UInt64 #

[View source]
def is_blocking_signals : Bool #

[View source]
def is_class(godot_class : String) : Bool #

[View source]
def is_connected(signal : String, callable : Pointer(Void)) : Bool #

[View source]
def is_queued_for_deletion : Bool #

[View source]
def is_valid? : Bool #

[View source]
def link_class_script : Void #

Automatically links this node's registered CrystalScript resource if running inside the Godot Editor


[View source]
def notification(what : Int64, reversed : Bool) : Void #

[View source]
def notify_property_list_changed : Void #

[View source]
def pointer : Pointer(Void) #

[View source]
def pointer=(val : Pointer(Void)) #

[View source]
def print(*args) #

Prints a message to Godot's debug console.


[View source]
def printerr(*args) #

Prints an error message to Godot's error console.


[View source]
def property_can_revert(property : String) : Bool #

[View source]
def property_get_revert(property : String) : Pointer(Void) #

[View source]
def puts(*args) #

Prints a message to Godot's debug console.


[View source]
def remove_meta(name : String) : Void #

[View source]
def remove_user_signal(signal : String) : Void #

[View source]
def set(property : String, value : Pointer(Void)) : Void #

[View source]
def set_block_signals(enable : Bool) : Void #

[View source]
def set_deferred(property : String, value : Pointer(Void)) : Void #

[View source]
def set_indexed(property_path : NodePath, value : Pointer(Void)) : Void #

[View source]
def set_message_translation(enable : Bool) : Void #

[View source]
def set_meta(name : String, value : Pointer(Void)) : Void #

[View source]
def set_script(script : Pointer(Void)) : Void #

[View source]
def set_translation_domain(domain : String) : Void #

[View source]
def signal(name : String) : Godot::BoundSignal #

Returns a bound signal representation for the named signal. Enables idiomatic usage: enemy.signal("died").await or button.signal("pressed").connect { ... }.


[View source]
def signal_connection_count(signal_name : String) : Int32 #

Returns the count of active subscriptions for the given signal on this object.


[View source]
def signal_target_id : UInt64 #

Identifier used for signal routing and lifecycle tracking (engine instance ID or Crystal object_id)


[View source]
def to_s(io : IO) : Void #
Description copied from class Reference

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>

[View source]
def to_string : String #

[View source]
def to_unsafe : Pointer(Void) #

Idiomatic Crystal pointer conversion


[View source]
def tr(message : String, context : String) : String #

[View source]
def tr_n(message : String, plural_message : String, n : Int64, context : String) : String #

[View source]