Skip to content

Commit 0d51aaa

Browse files
committed
Dodge-the-creeps: update OnReady::node() -> from_node()
1 parent fea4fc6 commit 0d51aaa

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

dodge-the-creeps/rust/src/main_scene.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ pub struct Main {
2323
impl INode for Main {
2424
fn init(base: Base<Node>) -> Self {
2525
// We could also initialize those manually inside ready(), but OnReady automatically defers initialization.
26+
// Alternatively to init(), you can use #[init(...)] on the struct fields.
2627
Self {
27-
mob_scene: OnReady::new(|| load("res://Mob.tscn")),
28-
player: OnReady::node("Player"),
29-
hud: OnReady::node("Hud"),
30-
music: OnReady::node("Music"),
31-
death_sound: OnReady::node("DeathSound"),
28+
// OnReady::from_loaded(path) == OnReady::new(|| tools::load(path)).
29+
mob_scene: OnReady::from_loaded("res://Mob.tscn"),
30+
player: OnReady::from_node("Player"),
31+
hud: OnReady::from_node("Hud"),
32+
music: OnReady::from_node("Music"),
33+
death_sound: OnReady::from_node("DeathSound"),
3234
score: 0,
3335
base,
3436
}

0 commit comments

Comments
 (0)