Вроде должно работать, ошибок нету, и в консоли получаю, что сцена работает. Но ни изображения, ни текста нету. Также не работает update, в чем может быть проблема?
export default class Play extends Phaser.Scene {
constructor () {
super('game');
this.staticBg = null;
this.scrollingBg = null;
this.text = null;
}
preload() {
this.load.image('background', 'img/Simpsons_22_15_P1_640x360_279961667900.jpg');
}
create() {
console.log("play");
this.staticBg = this.add.image(0, 0, 'background').setOrigin(0, 0).setScale(1.5, 1.7);
this.text = this.add.text(10, 70);
this.text.setText('Power: ' + 100);
}
update () {
this.scrollingBg.tilePositionY -= 1;
this.text.setText('Power: ' + 100);
}
}
Главный файл:
import Game from "./js/game";
import { Preload, Play } from './js/states';
const config = {
title: "Donuts",
width: 1000,
height: 800,
parent: "game",
// backgroundColor: "#18216D",
pixelArt: true,
scene: [
// Preload,
Play
],
physics: {
default: 'arcade',
arcade: {
debug: false,
gravity: { y: 300 }
}
}
};
let game;
window.onload = () => {
game = new Game(config);
game.start();
};