-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Added move_sprite example #2391
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
Conversation
examples/2d/move_sprite.rs
Outdated
} | ||
|
||
struct BevyLogo { | ||
rising: bool, |
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.
We should use an enum for this.
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.
I'm a bit new to rust and bevy ECS. can you explain why?
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.
Rust enums provide an extra level of type safety and you can also name the variants to be more descriptive.
effectively
enum Movement {
Rising,
Falling
}
and
bool
are equivalent.
However the Movement
enum is more descriptive as to what the two states actually represent.
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.
Especially if you call it something amusing like
Logomotion
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.
Simple, does what it says on the tin. Probably useful enough to beginners to be worth including.
examples/2d/move_sprite.rs
Outdated
.spawn_bundle(SpriteBundle { | ||
material: materials.add(texture_handle.into()), | ||
..Default::default() | ||
}) |
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.
could you add a transform component to show how to place a sprite from the start?
examples/2d/move_sprite.rs
Outdated
App::build() | ||
.add_plugins(DefaultPlugins) | ||
.add_startup_system(setup.system()) | ||
.add_system(sprite_movement.system()) |
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.
on main the .system()
syntax is no longer needed.
So we should probably also remove it here :)
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.
it can be done later, we will need a big pass on all examples anyway
Co-authored-by: Nathan Ward <[email protected]>
fixed line endings added space for CI changed to enum fixed formating fix formating again added transform to start. removed system
33a87b4
to
68e1a20
Compare
okay I messed up trying to update my branch so that optional system was implemented. Can someone help? |
If you can find the previous commit (before updating to main, reset to that branch)
Then when you update to main you want to rebase onto it.
My remote repo for bevy (not my personal fork) is aliased as It looks like the old commit hash you want is |
I just decided to redo the pull request since I seemed to mess it up more :( #2414 |
Objective
There is no bevy example that shows how to transform a sprite. At least as its singular purpose. This creates an example of how to use transform.translate to move a sprite up and down.
Solution
I created move_sprite example.