Setup Development Environment

Use as a plugin

Board plugin extends the phasers scene plugin. So to add it globally you have to follow this pattern. For more information see phaser docs.

import { BoardPlugin } from '<Path to BoardPlugin>';

const config = { 
  plugins: {
    scene: [{
      key: 'BoardPlugin',
      plugin: BoardPlugin,
      mapping: 'board',
      start: true
    }]
  },
}

new Phaser.Game(config);

then you can use it in any of your scenes (after boot and preload). you need to pass at least - the scene instance, where you want to make a board and one object for items. simple {} will create a 6 by 6 board with rectangle graphics.

let board = this.add.board(this, {});

Use as a class

To use as a class without adding to the plugin. simply require Board from BoardPlugin.

// inside a scene file. i.e. Game.js

import { Board } from '<Path to BoardPlugin>';

let init = new Board(this, {})

Result

simple 6x6