make the timer trigger (#935)

Co-authored-by: Tony <mostlyharmless@riseup.net>
This commit is contained in:
rmsthebest 2020-11-27 22:37:19 +01:00 committed by GitHub
parent ec8fd57c45
commit 01c4dd96cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,10 +9,12 @@ fn main() {
}
fn animate_sprite_system(
time: Res<Time>,
texture_atlases: Res<Assets<TextureAtlas>>,
mut query: Query<(&mut Timer, &mut TextureAtlasSprite, &Handle<TextureAtlas>)>,
) {
for (timer, mut sprite, texture_atlas_handle) in query.iter_mut() {
for (mut timer, mut sprite, texture_atlas_handle) in query.iter_mut() {
timer.tick(time.delta_seconds);
if timer.finished() {
let texture_atlas = texture_atlases.get(texture_atlas_handle).unwrap();
sprite.index = ((sprite.index as usize + 1) % texture_atlas.textures.len()) as u32;