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) #

Class Method Detail

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

Checks if this object class overrides a generic virtual method.


def self.find_script_path_for_class(target_cls : String) : String #

Discovers a .cr source file corresponding to a custom node/class


def self.is_instance_id_valid(id : Int | UInt64) : Bool #

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


Instance Method Detail

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

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


def ==(other : Nil) : Bool #

def _enter_tree : Void #

Lifecycle callback called when the node enters the tree hierarchy.


def _exit_tree : Void #

Lifecycle callback called when the node exits the tree hierarchy.


def _godot_call_tool_button(button_name : String) : Void #

Dispatches inspector tool button clicks on this object.


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).


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.


def _godot_get_property(prop_name : String, ret_ptr : Pointer(Void)) : Void #

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


def _godot_set_property(prop_name : String, val_ptr : Pointer(Void)) : Void #

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


def _physics_process(delta : Float64) : Void #

Fixed-rate physics process callback receiving delta timestep in seconds (Float64).


def _process(delta : Float64) : Void #

Per-frame process callback receiving delta timestep in seconds (Float64).


def _ready : Void #

Lifecycle callback called when the node enters the active scene tree.


def add_user_signal(signal : String, arguments : Pointer(Void)) : Void #

def alive? : Bool #

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


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

Cooperatively awaits a signal emitted on this object.


def blocking_signals? : Bool #

Predicate alias for #is_blocking_signals


def call(method : String, *args) : Pointer(Void) #

Calls the named method on the object with variable arguments.


def call_bool(method : String, *args) : Bool #

Calls the named method and returns the result as Bool


def call_deferred(method : String, *args) : Pointer(Void) #

Calls the named method on the object during idle time.


def call_f64(method : String, *args) : Float64 #

Calls the named method and returns the result as Float64


def call_i64(method : String, *args) : Int64 #

Calls the named method and returns the result as Int64


def call_obj(method : String, *args) : Node | Nil #

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


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)


def call_str(method : String, *args) : String #

Calls the named method and returns the result as String


def callv(method : String, arg_array : Pointer(Void)) : Pointer(Void) #

def can_translate_messages : Bool #

def can_translate_messages? : Bool #

Predicate alias for #can_translate_messages


def cancel_free : Void #

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.


def class?(godot_class : String) : Bool #

Predicate alias for #is_class


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.


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.


def connect(signal_name : Symbol, flags : Godot::ConnectFlags = ::Godot::ConnectFlags::None, &block : Array(Variant) -> Void) : SignalSubscription #

Connects a callback block to the named signal symbol.


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.


def connect(signal : String, callable : Pointer(Void), flags : Int64 = 0_i64) : Godot::Error #

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

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


def connected?(signal : String, callable : Pointer(Void)) : Bool #

Predicate alias for #is_connected


def destroy : Void #

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


def destroyed? : Bool #

def disconnect(signal : String, callable : Pointer(Void)) : Void #

def disconnect(signal_name : String) : Void #

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


def editor_hint? : Bool #

Returns true if running inside the Godot Editor


def emit_property_list_changed : Void #

def emit_script_changed : Void #

def emit_signal(name : String) : Void #

Emits a parameterless signal on this Godot object.


def emit_signal(name : String, *args) : Void #

Emits a signal with variable arguments on this Godot object.


def explicitly_freed? : Bool #

def free : Void #

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


def get(property : String) : Pointer(Void) #

def get_class : String #

def get_incoming_connections : Pointer(Void) #

def get_indexed(property_path : NodePath | String) : Pointer(Void) #

def get_instance_id : Int64 #

def get_meta(name : String, default : Pointer(Void) | Nil = nil) : Pointer(Void) #

def get_meta_list : Pointer(Void) #

def get_method_argument_count(method : String) : Int64 #

def get_method_list : Pointer(Void) #

def get_property_list : Pointer(Void) #

def get_script : Pointer(Void) #

def get_signal_connection_list(signal : String) : Pointer(Void) #

def get_signal_list : Pointer(Void) #

def get_translation_domain : String #

def has_connections(signal : String) : Bool #

def has_connections?(signal : String) : Bool #

Predicate alias for #has_connections


def has_meta(name : String) : Bool #

def has_meta?(name : String) : Bool #

Predicate alias for #has_meta


def has_method(method : String) : Bool #

def has_method?(method : String) : Bool #

Predicate alias for #has_method


def has_signal(signal : String) : Bool #

def has_signal?(signal_name : String) : Bool #

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


def has_user_signal(signal : String) : Bool #

def has_user_signal?(signal : String) : Bool #

Predicate alias for #has_user_signal


def hash(hasher) #

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


def if_alive : self | Nil #

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


def instance_id : UInt64 #

def is_blocking_signals : Bool #

def is_blocking_signals? : Bool #

Predicate alias for #is_blocking_signals


def is_class(godot_class : String) : Bool #

def is_class?(godot_class : String) : Bool #

Predicate alias for #is_class


def is_connected(signal : String, callable : Pointer(Void)) : Bool #

def is_connected?(signal : String, callable : Pointer(Void)) : Bool #

Predicate alias for #is_connected


def is_queued_for_deletion : Bool #

def is_queued_for_deletion? : Bool #

Predicate alias for #is_queued_for_deletion


def is_valid? : Bool #

def link_class_script : Void #

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


def notification(what : Int64, reversed : Bool = false) : Void #

def notify_property_list_changed : Void #

def pointer : Pointer(Void) #

def pointer=(val : Pointer(Void)) #

def print(*args) #

Prints a message to Godot's debug console.


def printerr(*args) #

Prints an error message to Godot's error console.


def property_can_revert(property : String) : Bool #

def property_can_revert?(property : String) : Bool #

Predicate alias for #property_can_revert


def property_get_revert(property : String) : Pointer(Void) #

def property_list_changed : Godot::TypedSignal() #

def puts(*args) #

Prints a message to Godot's debug console.


def queued_for_deletion? : Bool #

Predicate alias for #is_queued_for_deletion


def remove_meta(name : String) : Void #

def remove_user_signal(signal : String) : Void #

def script_changed : Godot::TypedSignal() #

def set(property : String, value : Pointer(Void)) : Void #

def set_block_signals(enable : Bool) : Void #

def set_deferred(property : String, value : Pointer(Void)) : Void #

def set_indexed(property_path : NodePath | String, value : Pointer(Void)) : Void #

def set_message_translation(enable : Bool) : Void #

def set_meta(name : String, value : Pointer(Void)) : Void #

def set_script(script : Pointer(Void)) : Void #

def set_translation_domain(domain : String) : Void #

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 { ... }.


def signal(sym : Symbol) : Godot::BoundSignal #

Returns a bound signal representation for the named signal symbol.


def signal_connection_count(signal_name : String) : Int32 #

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


def signal_target_id : UInt64 #

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


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>

def to_string : String #

def to_unsafe : Pointer(Void) #

Idiomatic Crystal pointer conversion


def tr(message : String, context : String = "") : String #

def tr_n(message : String, plural_message : String, n : Int64, context : String = "") : String #