Top Level Namespace

Defined in:

Method Summary

Macro Summary

Method Detail

def crystal_godot_init(api : Pointer(Godot::LibBridge::BridgeAPI)) : Void #

C ABI Entry point called by crystal_bridge when game library is loaded


[View source]
def load(path : String, type_hint : String = "", cache_mode : Int64 = 0_i64) : Godot::Resource #

Global convenience helper to load resources from Godot VFS


[View source]
def preload(path : String) : Godot::Resource #

Global convenience helper to preload resources from Godot VFS


[View source]
def vec2(x : Number, y : Number) : Vector2 #

Top-level math constructors


[View source]
def vec3(x : Number, y : Number, z : Number) : Vector3 #

[View source]

Macro Detail

macro abstract_class #

Convenience macro to designate a class as abstract in Godot.


[View source]
macro await(target, signal_name = nil, timeout_sec = nil) #

Top-level await macro for intuitive GDScript-like calling syntax Usage: await(enemy.died) await(enemy.died, timeout_sec: 2.0) await(enemy, "died") await(enemy, "died", timeout_sec: 2.0) await(timer.timeout) await(timer) await(1.5) await(2.seconds)


[View source]
macro export_category(name, &block) #

Categories group top-level inspector sections in Godot.

May be used standalone or as a block scoping exported properties:

export_category "Combat" do
  @[Export]
  property health : Int32 = 100
end

[View source]
macro export_group(name, prefix = "", &block) #

Groups exported properties in the Godot inspector.

May be used standalone or as a block scoping exported properties:

export_group "Movement", prefix: "move_" do
  @[Export]
  property move_speed : Float32 = 5.0_f32
end

[View source]
macro export_subgroup(name, prefix = "", &block) #

Subgroups exported properties under the current inspector group.

May be used standalone or as a block scoping exported properties:

export_subgroup "Advanced", prefix: "adv_" do
  @[Export]
  property adv_friction : Float32 = 0.1_f32
end

[View source]
macro gdclass(decl, &block) #

Declares a custom RefCounted or generic Godot engine class registered with ClassDB. Defaults to inheriting RefCounted when no parent is specified. Can be called with or without a block (e.g. gdclass MyState).

gdclass StateMachine < RefCounted do
  @[Export]
  property current_state : String = "idle"
end

gdclass SimpleState

[View source]
macro group(*group_names) #

Declaratively assigns the node to one or more scene tree groups upon _ready.

node Player < CharacterBody3D do
  group "players", "flammable"
end

[View source]
macro icon(path) #

Convenience macro to set a custom icon path in the editor.


[View source]
macro node(decl, &block) #

The primary node macro: Usage: node MyNode node MyNode do # defaults to Godot::Node end

node Player < CharacterBody3D node Player < CharacterBody3D do # inherits Godot::CharacterBody3D end


[View source]
macro node_path!(path) #

Creates a compile-time verified Godot::NodePath


[View source]
macro onready(decl) #

Declares an @onready node property initialized from the scene tree during _ready.


[View source]
macro onready(name, type, path = nil) #

Declares a lazy-cached node property matching Godot's @onready pattern.

Supports:

  1. Auto-inferred path: onready sprite_2d, Sprite2D (fetches "Sprite2D")
  2. Scene Unique Node: onready camera, Camera2D, "%MainCamera"
  3. Explicit path: onready sprite, Sprite2D, "Visuals/Sprite2D"

[View source]
macro resource(decl, &block) #

Declares a custom Godot Resource class registered with ClassDB and EditorHelp. Supports @[Export] properties, custom signals, and serialization to .tres.

resource ItemData < Resource do
  @[Export]
  property item_name : String = "Health Potion"

Declares a custom Resource subclass registered with ClassDB.
Defaults to inheriting `Resource` when no parent is specified.
Can be called with or without a block (e.g. `resource MyItem`).

```crystal
resource CustomPotion do
  @[Export]
  property item_name : String = "Health Potion"

  @[Export]
  property value : Int32 = 50
end

resource ShortItem

[View source]
macro signal(sig_decl) #

Declares a custom Godot signal and generates a type-safe emit_<signal_name> helper method.

class Player < Godot::CharacterBody3D
  signal health_changed(new_health : Int32, max_health : Int32)
  signal died

  def take_damage(amount : Int32)
    emit_health_changed(50, 100)
    emit_died if amount >= 100
  end
end

[View source]
macro static_unload #

Convenience macro to mark extension library unloading behavior.


[View source]
macro unique_node(name, type, unique_name = nil) #

Declares a lazy-cached Scene Unique Node property (Godot 4 %Node syntax).

Examples:

unique_node health_bar, ProgressBar # fetches "%HealthBar"
unique_node main_hud, CanvasLayer, "HUD" # fetches "%HUD"

[View source]
macro warning_ignore(name) #

Convenience macro to suppress compiler warnings.


[View source]
macro warning_ignore_restore(name) #

[View source]
macro warning_ignore_start(name) #

[View source]