File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
dodge-the-creeps/rust/src Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,14 @@ pub struct Main {
23
23
impl INode for Main {
24
24
fn init ( base : Base < Node > ) -> Self {
25
25
// 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.
26
27
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" ) ,
32
34
score : 0 ,
33
35
base,
34
36
}
You can’t perform that action at this time.
0 commit comments