/
aksjon
/
RNCB_Game
Обзор
Документация
Войти
/
aksjon
/
RNCB_Game
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
phaserjs_editor_scripts_base/UserComponent.js
43 строки
1 KB
aksjon
first_commit
18 май 2025, 19:19
18 май 2025, 19:19
f0429ce
Код
Авторство
О чём код?
export default class UserComponent { /** * @param gameObject The entity. */ constructor(gameObject) { this.scene = gameObject.scene; const listenAwake = this.awake !== UserComponent.prototype.awake; const listenStart = this.start !== UserComponent.prototype.start; const listenUpdate = this.update !== UserComponent.prototype.update; const listenDestroy = this.destroy !== UserComponent.prototype.destroy; if (listenAwake) { this.scene.events.once("scene-awake", this.awake, this); } if (listenStart) { this.scene.events.once(Phaser.Scenes.Events.UPDATE, this.start, this); } if (listenUpdate) { this.scene.events.on(Phaser.Scenes.Events.UPDATE, this.update, this); } if (listenStart || listenUpdate || listenDestroy) { gameObject.on(Phaser.GameObjects.Events.DESTROY, () => { this.scene.events.off(Phaser.Scenes.Events.UPDATE, this.start, this); this.scene.events.off(Phaser.Scenes.Events.UPDATE, this.update, this); if (listenDestroy) { this.destroy(); } }); } } scene; awake() { // override this } start() { // override this } update() { // override this } destroy() { // override this } }