MCPcopy Create free account
hub / github.com/Schr3da/gdext-rust-tutorials / init

Method init

singleton/rust/src/player.rs:15–30  ·  view source on GitHub ↗
(base: Base<Sprite2D>)

Source from the content-addressed store, hash-verified

13#[godot_api]
14impl ISprite2D for Player {
15 fn init(base: Base<Sprite2D>) -> Self {
16 match EXAMPLE_SINGLETON.lock() {
17 Err(e) => godot_error!("{:?}", e),
18 Ok(mut s) => {
19 s.add("EXAMPLE_SINGLETON: Not a registered Godot Singleton".to_string());
20 s.print();
21 }
22 };
23
24 match Engine::singleton().get_singleton("MyGodotSingleton") {
25 None => godot_error!("Failed to get singleton"),
26 Some(s) => s.try_cast::<MyGodotSingleton>().unwrap().bind().print(),
27 };
28
29 Self { base }
30 }
31
32 fn physics_process(&mut self, delta: f64) {
33 let radians = (3.14 * delta) as f32;

Callers

nothing calls this directly

Calls 2

addMethod · 0.80
printMethod · 0.45

Tested by

no test coverage detected