Quad
Introduction¶
Quad grid object of Board system.
- Author: Rex
- Grid object of board
Usage¶
Create instance¶
var grid = scene.rexBoard.add.quadGrid({
x: 0,
y: 0,
cellWidth: 0,
cellHeight: 0,
type: 0,
// dir: 4
});
or
// import { QuadGrid } from 'phaser3-rex-plugins/plugins/board-components.js';
var grid = new QuadGrid(config);
x,y: World position of tile (0, 0)cellWidth: The width of the cell, in pixels.cellHeight: The height of the cell, in pixels.type0, ororthogonal1, orisometric
dir:4or'4dir': Left/Down/Right/Up8or'8dir': Left/Down/Right/Up/Left-down/Down-right/Right-up/Up-left
World position of tile (0, 0)¶
- Get
var worldX = grid.x; var worldY = grid.y; - Set
or
grid.setOriginPosition(worldX, worldY);grid.x = worldX; grid.y = worldY;
Cell size¶
- Get
var width = grid.width; var height = grid.height; - Set
or
grid.setCellSize(width, height);grid.width = width; grid.height = height;
Grid type¶
- Get
var mode = grid.mode; - Set
grid.setType(mode);mode0, ororthogonal1, orisometric
Get world position¶
var worldXY = grid.getWorldXY(tileX, tileY); // worldXY: {x, y}
// var out = grid.getWorldXY(tileX, tileY, out);
Get tile position¶
var tileXY = grid.getTileXY(worldX, worldY); // tileXY: {x, y}
// var out = grid.getTileXY(worldX, worldY, out);
Directions¶
0: Right1: Down2: Left3: Up4: Right-down5: Left-down6: Left-up7: Right-up
6|3|7
-+-+-
2|A|0
-+-+-
5|1|4