Skip to content
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

Sprite Sheet Example: Skip "idle" frame. #5429

Closed
wants to merge 1 commit into from

Conversation

jmrepetti
Copy link

Objective

  • Make running animation fluid skipping 'idle' frame.

Solution

  • Replace TextureAtlas::from_grid() with TextureAtlas::from_grid_with_padding() and provide an offset of 1 tile.

The example is correct, is just the feeling that the animation loop is not seamless.

# Objective

- Make running animation fluid skipping 'idle' frame.

# Solution

- Replace `TextureAtlas::from_grid()` with `TextureAtlas::from_grid_with_padding()` and provide an offset of 1 tile.

The example is correct, is just the feeling that the animation loop is not seamless.
@mopsalarm
Copy link

mopsalarm commented Jul 23, 2022

Afaik with padding also skips the padding space between tiles. Did you intend to do that?
I needed to something similar in the past and just applied the offset to all the rects in the result of "from_grid".

@mockersf
Copy link
Member

I don't think not loading the first frame is the correct fix for that. instead, in the animate_sprite system, index 0 should be skipped

@mockersf mockersf added the C-Examples An addition or correction to our examples label Jul 23, 2022
@jmrepetti
Copy link
Author

Thanks for the comments.

@mockersf At some point I think you'll have different animations and trigger them somehow. That's why I thought on loading the running animation from the beginning instead of skipping indexes.

@mopsalarm I understood that padding will be used if tiles have some paddings, but in this case they don't, so I set it to Vec2.Zero.

But as I said, the example is correct and is about sprite sheet, not animations per se. I'm new to Bevy and was trying out the examples. Need to learn more. feel free to reject this PR if makes no sense :)

@mockersf
Copy link
Member

@mockersf At some point I think you'll have different animations and trigger them somehow. That's why I thought on loading the running animation from the beginning instead of skipping indexes.

In case of different animations, I think you should load only one texture atlas, not skipping any, and then say idle animation is frame 0 to 0 (in this case), running is frame 1 to 7, jumping 8 to 12, ...
You end up with ranges of index on which you'll iterate depending on the animation you play, not changing the texture atlas itself.

But as I said, the example is correct and is about sprite sheet, not animations per se. I'm new to Bevy and was trying out the examples. Need to learn more. feel free to reject this PR if makes no sense :)

It definitely looks better skipping the idle frame. It's funny how I never noticed it but now that you made the change it jumps to my eye 😄

bors bot pushed a commit that referenced this pull request Dec 11, 2022
# Objective

- Make running animation fluid skipping 'idle' frame.

## Solution

- Loop through the specified indices instead of through the whole sprite sheet.

The example is correct, is just the feeling that the animation loop is not seamless.

Based on the solution suggested by @mockersf in #5429.
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
# Objective

- Make running animation fluid skipping 'idle' frame.

## Solution

- Loop through the specified indices instead of through the whole sprite sheet.

The example is correct, is just the feeling that the animation loop is not seamless.

Based on the solution suggested by @mockersf in bevyengine#5429.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Make running animation fluid skipping 'idle' frame.

## Solution

- Loop through the specified indices instead of through the whole sprite sheet.

The example is correct, is just the feeling that the animation loop is not seamless.

Based on the solution suggested by @mockersf in bevyengine#5429.
@rparrett
Copy link
Contributor

rparrett commented Jan 9, 2024

With #6861 merged, it looks like this can be closed.

@rparrett rparrett closed this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Examples An addition or correction to our examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants