Created
August 5, 2014 22:16
-
-
Save pr00thmatic/fb277a6dde31b7a4ca22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function update() { | |
game.physics.arcade.collide(uno, walls); | |
cursores = game.input.keyboard.createCursorKeys(); | |
uno.animations.play('stand_' + lastDirection); // importante!! "uno" se queda quieto. | |
if(cursores.left.isDown) { | |
lastDirection = 'left'; | |
uno.scale.x = -1; | |
uno.body.velocity.x = -1*velocity; | |
uno.animations.play('right'); // importante!! reproducir animación de caminar hacia la izquierda | |
} else if (cursores.right.isDown) { | |
lastDirection = 'right'; | |
uno.scale.x = 1; | |
uno.body.velocity.x = 1*velocity; | |
uno.animations.play('right'); // importante!! reproducir animación de caminar hacia la derecha | |
} else if (cursores.up.isDown) { | |
lastDirection = 'up'; | |
uno.body.velocity.y = -1*velocity; | |
uno.animations.play('back') // importante!! reproducir animación de caminar hacia abajo | |
} else if (cursores.down.isDown) { | |
lastDirection = 'down'; | |
uno.body.velocity.y = 1*velocity; | |
uno.animations.play('front'); // importante!! reproducir animación de caminar hacia arriba | |
} else { | |
uno.body.velocity.x = 0; | |
uno.body.velocity.y = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment