Sprite
Introduction¶
Sprite chess object.
- Author: Rex
- Chess Game object of Board system
Usage¶
Install plugin¶
Load minify file¶
- Load plugin (minify file) in preload stage
scene.load.scenePlugin('rexboardplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexboardplugin.min.js', 'rexBoard', 'rexBoard');
- Add chess object
var chess = scene.rexBoard.add.sprite(board, tileX, tileY, tileZ, key, frame);
Import plugin¶
- Install rex plugins from npm
npm i phaser3-rex-plugins
- Install plugin in configuration of game
import BoardPlugin from 'phaser3-rex-plugins/plugins/board-plugin.js'; var config = { // ... plugins: { scene: [{ key: 'rexBoard', plugin: BoardPlugin, mapping: 'rexBoard' }, // ... ] } // ... }; var game = new Phaser.Game(config);
- Add chess object
var chess = scene.rexBoard.add.sprite(board, tileX, tileY, tileZ, key, frame);
Import class¶
- Install rex plugins from npm
npm i phaser3-rex-plugins
- Import class
import { Sprite } from 'phaser3-rex-plugins/plugins/board-components.js';
- Add chess object
var chess = new Sprite(board, tileX, tileY, tileZ, key, frame); scene.add.existing(chess);
Add chess object¶
- Create chess object and add to board
var chess = scene.rexBoard.add.sprite(board, tileX, tileY, tileZ, key, frame);
board
: Board objecttileX
,tileY
,tileZ
: Tile positionkey
,frame
: Frame of this sprite chess object
- Create chess object but not add to board
var chess = scene.rexBoard.add.sprite(board, x, y, undefined, key, frame, false);
board
: Board objectx
,y
: World positionkey
,frame
: Frame of this sprite chess object