Skip to content

Commit

Permalink
fix flip of contributor bird (#1573)
Browse files Browse the repository at this point in the history
Since 8921717, some birds in example `contributors` where not colored.

Fix is to use `flip_x` of `Sprite` instead of setting `transform.scale.x` to `-1` as described in #1407.


It may be an unintended side effect, as now we can't easily display a colored sprite while changing it's scale from `1` to `-1`, we would have to change it's scale from `1` to `0`, then flip it, then change scale from `0` to `1`.
  • Loading branch information
mockersf committed Mar 7, 2021
1 parent a730815 commit 58d687b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn build_sprite_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor
topology: PrimitiveTopology::TriangleList,
strip_index_format: None,
front_face: FrontFace::Ccw,
cull_mode: CullMode::Back,
cull_mode: CullMode::None,
polygon_mode: PolygonMode::Fill,
},
..PipelineDescriptor::new(ShaderStages {
Expand Down
4 changes: 2 additions & 2 deletions examples/2d/contributors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ fn setup(
// some sprites should be flipped
let flipped = rnd.gen_bool(0.5);

let mut transform = Transform::from_xyz(pos.0, pos.1, 0.0);
transform.scale.x *= if flipped { -1.0 } else { 1.0 };
let transform = Transform::from_xyz(pos.0, pos.1, 0.0);

commands
.spawn((Contributor { color: col },))
Expand All @@ -87,6 +86,7 @@ fn setup(
sprite: Sprite {
size: Vec2::new(1.0, 1.0) * SPRITE_SIZE,
resize_mode: SpriteResizeMode::Manual,
flip_x: flipped,
..Default::default()
},
material: materials.add(ColorMaterial {
Expand Down

0 comments on commit 58d687b

Please sign in to comment.