Skip to main content

Crate spire_tween

Crate spire_tween 

Source
Expand description

Tweening library for Godot 4 via gdext, inspired by Unity’s DOTween.

§Quickstart

use spire_tween::prelude::*;

// Tween a known property — returns a builder. Don't forget `.register()`.
let handle = my_node
    .do_position(Vector2::new(640.0, 360.0), 2.0)
    .with_ease(EaseKind::Basic(Ease::OutCubic))
    .as_relative(Vector2::ZERO)
    .register();

// Hook a callback for when it finishes (closure-based, Rust-only path).
handle.to_mut().finished_connect(
    || godot_print!("done!"),
    SpireFlags::DEFERRED | SpireFlags::ONE_SHOT,
);

// Sequence multiple tweens.
let mut seq = SpireTween::<Sequence>::new();
seq.append(my_node.do_position(target_a, 1.0));
seq.join(my_node.do_color(Color::RED, 1.0));   // parallel with the above
seq.append(my_node.do_position(target_b, 1.0));
seq.register();

§The prelude

use spire_tween::prelude::* brings in the core surface:

§Two register paths

Pick based on who needs to listen for finished / loop_finished:

§Cargo features

  • default = ["indexmap"] — backing storage for the per-frame deferred-op map.
  • standalone — registers GDScript-facing classes (Spire, SpireSequence, Do{Class}, etc.). Enabled by the spire_tween_plugin cdylib that produces the published addon. Pure-Rust gdext consumers don’t need this.
  • dashmap — alternative concurrent map backend (mutually exclusive with indexmap).
  • indexmap — single-threaded ordered map backend (the default).
  • double-precision — forwards to godot’s double-precision feature for 64-bit Vector*/real. Match this with your gdext build.
  • nothreads — forwards to godot’s experimental-wasm-nothreads for wasm builds without thread support.
  • verbose-stdout — extra diagnostic prints inside the manager loop.

§Threading

Spire is single-threaded — same constraint as Godot’s main loop. The internal RcPtr<T> is a Rc<UnsafeCell<T>> wrapper that relies on Godot’s main-thread invariant; do not register or access tweens from worker threads.

§In-editor docs (GDScript audience)

When the standalone feature is enabled, the GDScript-facing classes are registered with rich godot-flavored docs (extracted via the register-docs gdext feature). Those are what shows up in the Godot editor’s class browser. The Rust API documented here mirrors the same concepts; the GDScript layer is built on top.

Modules§

prelude

Macros§

print_every_nth_frame
print_with_frame