nPhoenix

PIX.RPG - Code concept

Sep 27th, 2020
1,182
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Phaser from "phaser";
  2. import PIX from "@/core";
  3.  
  4. class DemoScene extends PIX.RPG.Scene.Raw {
  5.     constructor (config) {
  6.         super(config);
  7.     }
  8.  
  9.     preload () {
  10.         this.raw.load.image("logo", "/assets/logo.png");
  11.     }
  12.  
  13.     init (params) {
  14.         console.log("Scene transition delay", Date.now() - params.date);
  15.     }
  16.  
  17.     create () {
  18.         const image = this.raw.add.image(400, 150, "logo");
  19.     }
  20. }
  21.  
  22. class CustomOverworld extends PIX.RPG.Scene.Overworld {
  23.     constructor (config) {
  24.         super(config);
  25.     }
  26.  
  27.     create () {
  28.         super.create();
  29.  
  30.         this.player.setSkin(0);
  31.  
  32.         this.raw.time.addEvent({
  33.             delay: 100,
  34.             callback: this.changeScene,
  35.             scope: this
  36.         });
  37.     }
  38.  
  39.     changeScene () {
  40.         this.scene.change("demo", {
  41.             date: Date.now()
  42.         });
  43.     }
  44. };
  45.  
  46. const gameInstace = new PIX.RPG.Game({
  47.     type: PIX.WEBGL,
  48.     resolution: PIX.RESOLUTION.STANDART,
  49.     parent: "container",
  50.     scale: true,
  51.     configFile: "/config/gameconfig.js"
  52. });
  53.  
  54. gameInstace.scene.override(PIX.SCENE.OVERWORLD, CustomOverworld);
  55.  
  56. gameInstace.scene.add("demo", DemoScene);
  57.  
  58. gameInstace.start();
RAW Paste Data