In the Bevy book the following code is used:
struct GreetTimer(Timer);
fn greet_people(
time: Res<Time>, mut timer: ResMut<GreetTimer>, query: Query<&Name, With<Person>>) {
// update our timer with the time elapsed since the last update
// if that caused the timer to finish, we say hello to everyone
if timer.0.tick(time.delta()).just_finished() {
for name in query.iter() {
println!("hello {}!", name.0);
}
}
}
What are the timer.0
and name.0
calls doing? The book doesn't address it, and I see that Timer
has a tick method, so what is .0
doing here since timer
is already a Timer
?
GreetTimer
, notTimer
. And GreetTimer is a tuple struct, so you have to access its first (and only) element, asGreetTimer
itself does not define atick()
method. – Gunny