Advertisement
nPhoenix

ScenesManager.js

Feb 26th, 2021
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Phaser from "phaser";
  2.  
  3. class ScenesManager {
  4.     constructor () {
  5.         this.overworld;
  6.         this.level;
  7.         this.battle;
  8.     }
  9.  
  10.     setOverworld (scene) {
  11.         this.overworld = scene;
  12.     }
  13.  
  14.     setLevel (scene) {
  15.         this.level = scene;
  16.     }
  17.  
  18.     setBattle (scene) {
  19.         this.battle = scene;
  20.     }
  21.  
  22.     getOverworld () {
  23.         return this.overworld;
  24.     }
  25.  
  26.     getLevel () {
  27.         return this.level;
  28.     }
  29.  
  30.     getBattle () {
  31.         return this.battle;
  32.     }
  33.  
  34.     destroy (scene) {
  35.         if (scene in this && this[scene] instanceof Phaser.Scene) {
  36.             this[scene].destroy();
  37.             return true;
  38.         };
  39.  
  40.         return false;
  41.     }
  42.  
  43.     destroyAll () {
  44.         Object.keys(this)
  45.             .filter(attr => attr instanceof Phaser.Scene)
  46.             .forEach(scene => scene.destroy());
  47.     }
  48.  
  49.     static ref
  50. }
  51.  
  52.  
  53. export default ScenesManager;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement