serban123 Posted January 11, 2020 Share Posted January 11, 2020 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.