hi there ! i’m new to phaser and javascript and i can’t figure out how to make my player move in a custom class
class Fish extends Phaser.GameObjects.Sprite{
constructor(scene, x, y){
super(scene, x, y, 'fish', '3');
this.scene.add.existing(this);
scene.physics.world.enableBody(this);
this.body.setGravityY(660);
this.body.setCollideWorldBounds(true);
}
update(){
if (scene.cursors.right.isDown) {
this.body.setVelocityX(190);
} else if (scene.cursors.left.isDown) {
this.body.setVelocityX(-190);
} else {
this.body.setVelocityX(0);
}
}
}
this.cursors = this.input.keyboard.createCursorKeys();
this.player = this.add.existing(new Fish(this, 100, 0));
or should i create move functions and call them in scene.js?(not sure how to do that either…) can anyone help?