From 4b0464a6324f228a528fd1759a773a61facfa1eb Mon Sep 17 00:00:00 2001 From: jestarray <34615798+jestarray@users.noreply.github.com> Date: Wed, 23 Jan 2019 11:30:08 -0800 Subject: [PATCH] Updated tilemap jsdocs --- src/tilemaps/Tilemap.js | 4 +-- src/tilemaps/mapdata/LayerData.js | 24 +++++++-------- src/tilemaps/mapdata/MapData.js | 51 +++++++++++++++++++++++-------- 3 files changed, 53 insertions(+), 26 deletions(-) diff --git a/src/tilemaps/Tilemap.js b/src/tilemaps/Tilemap.js index bf8badf7e..36f62bf84 100644 --- a/src/tilemaps/Tilemap.js +++ b/src/tilemaps/Tilemap.js @@ -717,8 +717,8 @@ var Tilemap = new Class({ * * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. - * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} [x=0] - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} [y=0] - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. * * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. */ diff --git a/src/tilemaps/mapdata/LayerData.js b/src/tilemaps/mapdata/LayerData.js index fdddd557b..f4a0d5b9e 100644 --- a/src/tilemaps/mapdata/LayerData.js +++ b/src/tilemaps/mapdata/LayerData.js @@ -29,7 +29,7 @@ var LayerData = new Class({ if (config === undefined) { config = {}; } /** - * [description] + * The name of the layer(specified in Tiled) * * @name Phaser.Tilemaps.LayerData#name * @type {string} @@ -38,7 +38,7 @@ var LayerData = new Class({ this.name = GetFastValue(config, 'name', 'layer'); /** - * [description] + * The x offset of where to draw from the top left * * @name Phaser.Tilemaps.LayerData#x * @type {number} @@ -47,7 +47,7 @@ var LayerData = new Class({ this.x = GetFastValue(config, 'x', 0); /** - * [description] + * The y offset of where to draw from the top left * * @name Phaser.Tilemaps.LayerData#y * @type {number} @@ -56,7 +56,7 @@ var LayerData = new Class({ this.y = GetFastValue(config, 'y', 0); /** - * [description] + * The width in tile units of the layer. * * @name Phaser.Tilemaps.LayerData#width * @type {number} @@ -65,7 +65,7 @@ var LayerData = new Class({ this.width = GetFastValue(config, 'width', 0); /** - * [description] + * The height in tiles units of the layer. * * @name Phaser.Tilemaps.LayerData#height * @type {number} @@ -74,7 +74,7 @@ var LayerData = new Class({ this.height = GetFastValue(config, 'height', 0); /** - * [description] + * The pixel width of the tiles. * * @name Phaser.Tilemaps.LayerData#tileWidth * @type {number} @@ -83,7 +83,7 @@ var LayerData = new Class({ this.tileWidth = GetFastValue(config, 'tileWidth', 0); /** - * [description] + * The pixel height of the tiles. * * @name Phaser.Tilemaps.LayerData#tileHeight * @type {number} @@ -110,7 +110,7 @@ var LayerData = new Class({ this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight); /** - * [description] + * The width in pixels of the entire layer. * * @name Phaser.Tilemaps.LayerData#widthInPixels * @type {number} @@ -119,7 +119,7 @@ var LayerData = new Class({ this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth); /** - * [description] + * The height in pixels of the entire layer. * * @name Phaser.Tilemaps.LayerData#heightInPixels * @type {number} @@ -146,7 +146,7 @@ var LayerData = new Class({ this.visible = GetFastValue(config, 'visible', true); /** - * [description] + * Layer specific properties (can be specified in Tiled) * * @name Phaser.Tilemaps.LayerData#properties * @type {object} @@ -191,10 +191,10 @@ var LayerData = new Class({ this.bodies = GetFastValue(config, 'bodies', []); /** - * [description] + * An array of the tile indexes * * @name Phaser.Tilemaps.LayerData#data - * @type {array} + * @type {(number[])} * @since 3.0.0 */ this.data = GetFastValue(config, 'data', []); diff --git a/src/tilemaps/mapdata/MapData.js b/src/tilemaps/mapdata/MapData.js index 3f1112e3a..2d23f12fd 100644 --- a/src/tilemaps/mapdata/MapData.js +++ b/src/tilemaps/mapdata/MapData.js @@ -6,6 +6,33 @@ var Class = require('../../utils/Class'); var GetFastValue = require('../../utils/object/GetFastValue'); +var LayerData = require('./LayerData'); +var ObjectLayer = require("./ObjectLayer"); +var Tileset = require('../Tileset'); + +/** + * @typedef {object} MapDataConfig + * @property {string} [name] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @property {number} [width=0] - The width of the entire tilemap. + * @property {number} [height=0] - The height of the entire tilemap. + * @property {number} [tileWidth=0] - The width of the tiles. + * @property {number} [tileHeight=0] - The height of the tiles. + * @property {number} [widthInPixels] - The width in pixels of the entire tilemap. + * @property {number} [heightInPixels] - The height in pixels of the entire tilemap. + * @property {number} [widthInPixels=0] - The pixel size of the entire tilemap. + * @property {integer} [format] - [description] + * @property {string} [orientation] - The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. + * @property {string} [renderOrder] - Determines the draw order of tilemap. Default is right-down. + * @property {number} [version] - The version of Tiled the map uses. + * @property {number} [properties] - Map specific properties (can be specified in Tiled). + * @property {LayerData[]} [layers] - The layers of the tilemap. + * @property {array} [images] - An array with all the layers configured to the MapData. + * @property {object} [objects] - An array of Tiled Image Layers. + * @property {object} [collision] - An object of Tiled Object Layers. + * @property {Tileset[]} [tilesets] - The tilesets the map uses. + * @property {array} [imageCollections] - The collection of images the map uses(specified in Tiled). + * @property {array} [tiles] - [description] + */ /** * @classdesc @@ -18,7 +45,7 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * @constructor * @since 3.0.0 * - * @param {object} [config] - [description] + * @param {MapDataConfig} [config] - [description] */ var MapData = new Class({ @@ -29,7 +56,7 @@ var MapData = new Class({ if (config === undefined) { config = {}; } /** - * [description] + * The key in the Phaser cache that corresponds to the loaded tilemap data. * * @name Phaser.Tilemaps.MapData#name * @type {string} @@ -38,7 +65,7 @@ var MapData = new Class({ this.name = GetFastValue(config, 'name', 'map'); /** - * [description] + * The width of the entire tilemap. * * @name Phaser.Tilemaps.MapData#width * @type {number} @@ -47,7 +74,7 @@ var MapData = new Class({ this.width = GetFastValue(config, 'width', 0); /** - * [description] + * The height of the entire tilemap. * * @name Phaser.Tilemaps.MapData#height * @type {number} @@ -56,7 +83,7 @@ var MapData = new Class({ this.height = GetFastValue(config, 'height', 0); /** - * [description] + * The width of the tiles. * * @name Phaser.Tilemaps.MapData#tileWidth * @type {number} @@ -65,7 +92,7 @@ var MapData = new Class({ this.tileWidth = GetFastValue(config, 'tileWidth', 0); /** - * [description] + * The height of the tiles. * * @name Phaser.Tilemaps.MapData#tileHeight * @type {number} @@ -74,7 +101,7 @@ var MapData = new Class({ this.tileHeight = GetFastValue(config, 'tileHeight', 0); /** - * [description] + * The width in pixels of the entire tilemap. * * @name Phaser.Tilemaps.MapData#widthInPixels * @type {number} @@ -83,7 +110,7 @@ var MapData = new Class({ this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.tileWidth); /** - * [description] + * The height in pixels of the entire tilemap. * * @name Phaser.Tilemaps.MapData#heightInPixels * @type {number} @@ -145,7 +172,7 @@ var MapData = new Class({ * An array with all the layers configured to the MapData. * * @name Phaser.Tilemaps.MapData#layers - * @type {array} + * @type {Array.} * @since 3.0.0 */ this.layers = GetFastValue(config, 'layers', []); @@ -169,7 +196,7 @@ var MapData = new Class({ this.objects = GetFastValue(config, 'objects', {}); /** - * An object of collision data. Must be created as physics object or will return undefined. + * An object of collision data. Must be created as physics object or will return undefined. * * @name Phaser.Tilemaps.MapData#collision * @type {object} @@ -181,13 +208,13 @@ var MapData = new Class({ * An array of Tilesets. * * @name Phaser.Tilemaps.MapData#tilesets - * @type {array} + * @type {Tileset[]} * @since 3.0.0 */ this.tilesets = GetFastValue(config, 'tilesets', []); /** - * [description] + * The collection of images the map uses(specified in Tiled) * * @name Phaser.Tilemaps.MapData#imageCollections * @type {array}