Skip to content

Commit

Permalink
Update sandbox with new key api
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Sep 18, 2015
1 parent f122003 commit df66673
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sandbox/web/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ var jumpSpeed = 500;
var direction = 1;
player.on('update', () => {

if (game.input.keyboard.isKeyPressed(ex.Input.Keys.Left)) {
if (game.input.keyboard.isHeld(ex.Input.Keys.Left)) {
direction = -1;
if (!inAir) {
player.setDrawing(Animations.Left);
Expand All @@ -218,7 +218,7 @@ player.on('update', () => {

// TODO: When platform is moving in same direction, add its dx

} else if (game.input.keyboard.isKeyPressed(ex.Input.Keys.Right)) {
} else if (game.input.keyboard.isHeld(ex.Input.Keys.Right)) {
direction = 1;
if (!inAir) {
player.setDrawing(Animations.Right);
Expand All @@ -232,7 +232,7 @@ player.on('update', () => {
// TODO: When platform is moving in same direction, add its dx
}

if (game.input.keyboard.isKeyPressed(ex.Input.Keys.Up)) {
if (game.input.keyboard.isHeld(ex.Input.Keys.Up)) {
if (!inAir) {
player.dy = -jumpSpeed;
inAir = true;
Expand Down Expand Up @@ -320,7 +320,7 @@ player.addEventListener('collision', (data?: ex.CollisionEvent) => {
player.setDrawing(Animations.Idle);
}
inAir = false;
if (data.other && !(game.input.keyboard.isKeyPressed(ex.Input.Keys.Left) || game.input.keyboard.isKeyPressed(ex.Input.Keys.Right) || game.input.keyboard.isKeyPressed(ex.Input.Keys.Up) || game.input.keyboard.isKeyPressed(ex.Input.Keys.Down))) {
if (data.other && !(game.input.keyboard.isHeld(ex.Input.Keys.Left) || game.input.keyboard.isHeld(ex.Input.Keys.Right) || game.input.keyboard.isHeld(ex.Input.Keys.Up) || game.input.keyboard.isHeld(ex.Input.Keys.Down))) {
player.dx = data.other.dx;
player.dy = data.other.dy;
}
Expand Down

0 comments on commit df66673

Please sign in to comment.