load()

Loading layer structure...

When preloading your scene, use P2P.load() by passing in the folder generated by PSDtoJSON. Any assets in the JSON that do not have a lazyLoad:true attribute will start loading. Events are emitted as each asset is loaded.

// Load the JSON
this.P2P.load.load(this, "psd_key", "assets/simple");

// Load with lazyLoad options - set all layers to lazy load
this.P2P.load.load(this, "psd_key", "assets/simple", {
  lazyLoad: true
});

// Load with lazyLoad options - set specific layers to lazy load
this.P2P.load.load(this, "psd_key", "assets/simple", {
  lazyLoad: ["background", "monster"]
});

Loading Events

Listen for loading progress and completion events:

// Listen for asset loading progress
this.events.on("psdLoadProgress", (value) => {
  console.log(`Loading: ${(value * 100).toFixed(0)}%`);
});

// Listen for asset loading completion
this.events.once("psdLoadComplete", () => {
  console.log("All done!");
});