Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- You can now import [yal.cc](https://yal.cc/tools/pixel-font/) fonts directly from the json + png / aseprite file without having to go via ttf.

### Changed

- `Tag::animation_frame` now increments the provided frame.

## [0.23.1] - 2026/02/07

- Minor release to fix problems with publishing 0.23.0.
Expand Down
6 changes: 4 additions & 2 deletions agb/src/display/object/sprites/sprite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl Tag {
/// animating sprites efficiently.
pub fn animation_frame(&self, idx: &mut usize, divider: u32) -> &'static Sprite {
let divided = *idx >> divider;
let idx = match self.direction {
let frame = match self.direction {
Direction::Forward => {
if divided >= self.sprites.len() {
*idx = 0;
Expand Down Expand Up @@ -362,7 +362,9 @@ impl Tag {
}
};

&self.sprites[idx]
*idx += 1;

&self.sprites[frame]
}

#[doc(hidden)]
Expand Down
2 changes: 0 additions & 2 deletions book/games/platform/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ impl Player {
}

fn update_sprite(&mut self) {
self.frame += 1;

if self.velocity.x > num!(0.1) {
self.flipped = false;
}
Expand Down
2 changes: 0 additions & 2 deletions book/src/platformer/06_the_player.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ We need to update the sprite based on the player's state:
```rust
impl Player {
fn update_sprite(&mut self) {
self.frame += 1;

// We need to keep track of the facing direction rather than
// deriving it because the zero velocity case needs to keep
// facing the same direction.
Expand Down