-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add index_range for TextureAtlas #16611
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,10 @@ fn execute_animations(time: Res<Time>, mut query: Query<(&mut AnimationConfig, & | |
if let Some(atlas) = &mut sprite.texture_atlas { | ||
if atlas.index == config.last_sprite_index { | ||
// ...and it IS the last frame, then we move back to the first frame and stop. | ||
atlas.index = config.first_sprite_index; | ||
atlas.advance_index(); | ||
} else { | ||
// ...and it is NOT the last frame, then we move to the next frame... | ||
atlas.index += 1; | ||
atlas.advance_index(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, this change looks subtly wrong to me. Previously the logic was:
Now the logic is (due to
Even if this particular change is the same as before (I didn't completely check because it looks subtly wrong and it's no longer intuitive, at least to me), my main concerns are left in a comment at the end of the review. |
||
// ...and reset the frame timer to start counting all over again | ||
config.frame_timer = AnimationConfig::timer_from_fps(config.fps); | ||
} | ||
|
@@ -106,6 +106,7 @@ fn setup( | |
texture_atlas: Some(TextureAtlas { | ||
layout: texture_atlas_layout.clone(), | ||
index: animation_config_1.first_sprite_index, | ||
index_range: (animation_config_1.first_sprite_index, animation_config_1.last_sprite_index), | ||
}), | ||
..default() | ||
}, | ||
|
@@ -124,6 +125,7 @@ fn setup( | |
texture_atlas: Some(TextureAtlas { | ||
layout: texture_atlas_layout.clone(), | ||
index: animation_config_2.first_sprite_index, | ||
index_range: (animation_config_2.first_sprite_index, animation_config_2.last_sprite_index), | ||
}), | ||
..Default::default() | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ fn button_system( | |
Interaction::Pressed => { | ||
**text = "Press".to_string(); | ||
if let Some(atlas) = &mut image.texture_atlas { | ||
atlas.index = (atlas.index + 1) % 30; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is supposed to cycle |
||
atlas.advance_index(); | ||
} | ||
image.color = GOLD.into(); | ||
} | ||
|
@@ -87,6 +87,7 @@ fn setup( | |
TextureAtlas { | ||
index: idx, | ||
layout: atlas_layout_handle.clone(), | ||
index_range: (idx, 30) | ||
}, | ||
) | ||
.with_mode(NodeImageMode::Sliced(slicer.clone())), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it should just use a saturating add.