Quad

Introduction

Quad grid object of Board system.

  • Author: Rex
  • Grid object of board

Usage

Sample code

Create instance

var grid = scene.rexBoard.add.quadGrid({
    x: 0,
    y: 0,
    cellWidth: 0,
    cellHeight: 0,
    type: 0,
    // dir: 4
});
  • x, y : World position of tile (0, 0)
  • cellWidth : The width of the cell, in pixels.
  • cellHeight : The height of the cell, in pixels.
  • type
    • 0, or orthogonal
    • 1, or isometric
  • dir :
    • 4 or '4dir' : Left/Down/Right/Up
    • 8 or '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
    grid.setOriginPosition(worldX, worldY);
    
    or
    grid.x = worldX;
    grid.y = worldY;
    

Cell size

  • Get
    var width = grid.width;
    var height = grid.height;
    
  • Set
    grid.setCellSize(width, height);
    
    or
    grid.width = width;
    grid.height = height;
    

Grid type

  • Get
    var mode = grid.mode;
    
  • Set
    grid.setType(mode);
    
    • mode
      • 0, or orthogonal
      • 1, or isometric

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 : Left
  • 1 : Down
  • 2 : Right
  • 3 : Up
  • 4 : Left-down
  • 5 : Down-right
  • 6 : Right-up
  • 7 : Up-left