class ExampleScene extends Phaser.Scene {
ball;
// ...
}Move the ball / notebook
Move the ball
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
class ExampleScene extends Phaser.Scene {
// ...
preload() {
this.load.image("ball", "img/ball.png");
}
// ...
}class ExampleScene extends Phaser.Scene {
// ...
create() {
this.ball = this.add.sprite(50, 50, "ball");
}
// ...
}class ExampleScene extends Phaser.Scene {
// ...
update() {
this.ball.x += 1;
this.ball.y += 1;
}
}