serban123

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. I am learning Phaser 3 and I am trying to move a sprite but it doesnt move. This is the code: var config = { type: Phaser.AUTO, width: 450, height: 450, scene: { preload: preload, create: create, update: update } }; var game = new Phaser.Game(config); var cursors; function preload() { this.load.image('sky','back.jpg'); this.load.image('logo','logo.png') } function create() { this.add.image(0,0,'sky').setOrigin(0); player = this.add.sprite(200,200,'logo'); player.setCollideWorldBounds(true); cursors = this.input.keyboard.createCursorKeys(); } function update() { if (this.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { player.x -= 4; } else if (this.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { player.x += 4; } if (this.input.keyboard.isDown(Phaser.Keyboard.UP)) { player.y -= 4; } else if (this.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { player.y += 4; } } Thank you in advance