Fix the left/right movement direction in state example. (#1879)

Direction of movement was reversed, previously.

(i.e. Left arrow key moved sprite to the right; Right arrow key moved sprite to the left.)

This PR changes the code to now be consistent with, for example, the breakout example: 81b53d15d4/examples/game/breakout.rs (L184-L190)

i.e. AFAICT it's not an issue with the keycode being different/wrong.
This commit is contained in:
follower 2021-04-14 23:39:56 +00:00
parent 294feeedc0
commit 57e3d4f1c2

View file

@ -119,10 +119,10 @@ fn movement(
for mut transform in query.iter_mut() {
let mut direction = Vec3::ZERO;
if input.pressed(KeyCode::Left) {
direction.x += 1.0;
direction.x -= 1.0;
}
if input.pressed(KeyCode::Right) {
direction.x -= 1.0;
direction.x += 1.0;
}
if input.pressed(KeyCode::Up) {
direction.y += 1.0;