DigitMagazine

Devworx Jan 2019 Adding controls

Dec 25th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. cursors = this.input.keyboard.createCursorKeys();
  2. if (cursors.left.isDown)
  3. {
  4.    player.setVelocityX(-160);
  5.  
  6.    player.anims.play('left', true);
  7. }
  8. else if (cursors.right.isDown)
  9. {
  10.    player.setVelocityX(160);
  11.  
  12.    player.anims.play('right', true);
  13. }
  14. else
  15. {
  16.    player.setVelocityX(0);
  17.  
  18.    player.anims.play('turn');
  19. }
  20.  
  21. if (cursors.up.isDown && player.body.touching.down)
  22. {
  23.    player.setVelocityY(-330);
  24. }
Add Comment
Please, Sign In to add comment