From 09224b724e479b9591896d315b1872c061d7c252 Mon Sep 17 00:00:00 2001 From: Michael Hadley Date: Sun, 26 Nov 2017 09:05:19 -0600 Subject: [PATCH] Tilemap: adding jsdocs --- .../tilemap/components/CalculateFacesWithin.js | 11 +++++++++++ v3/src/gameobjects/tilemap/components/Copy.js | 17 ++++++++++++++++- .../gameobjects/tilemap/components/CullTiles.js | 9 +++++++++ .../tilemap/components/GetTilesWithinShape.js | 4 ++-- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/v3/src/gameobjects/tilemap/components/CalculateFacesWithin.js b/v3/src/gameobjects/tilemap/components/CalculateFacesWithin.js index 5b8bd4f86..2f29e6701 100644 --- a/v3/src/gameobjects/tilemap/components/CalculateFacesWithin.js +++ b/v3/src/gameobjects/tilemap/components/CalculateFacesWithin.js @@ -1,6 +1,17 @@ var GetTileAt = require('./GetTileAt'); var GetTilesWithin = require('./GetTilesWithin'); +/** + * Calculates interesting faces within the rectangular area specified (in tile coordinates). + * Interesting faces are used internally for optimizing collisions against tiles. This method is + * mostly used internally. + * + * @param {number} [tileX=0] - [description] + * @param {number} [tileY=0] - [description] + * @param {number} [width=max width based on tileX] - [description] + * @param {number} [height=max height based on tileY] - [description] + * @param {LayerData} layer - [description] + */ var CalculateFacesWithin = function (tileX, tileY, width, height, layer) { var above = null; diff --git a/v3/src/gameobjects/tilemap/components/Copy.js b/v3/src/gameobjects/tilemap/components/Copy.js index 30145cf40..e9b7ac420 100644 --- a/v3/src/gameobjects/tilemap/components/Copy.js +++ b/v3/src/gameobjects/tilemap/components/Copy.js @@ -1,7 +1,22 @@ var GetTilesWithin = require('./GetTilesWithin'); var CalculateFacesWithin = require('./CalculateFacesWithin'); -// Copies indices, not other properties. Does not modify collisions. +/** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates). This copies all tile properties & recalculates interesting tile faces in the + * destination region. + * + * @param {number} srcTileX - [description] + * @param {number} srcTileY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} destTileX - [description] + * @param {number} destTileY - [description] + * @param {number} destTileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {LayerData} layer - [description] + */ + var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) { if (srcTileX < 0) { srcTileX = 0; } diff --git a/v3/src/gameobjects/tilemap/components/CullTiles.js b/v3/src/gameobjects/tilemap/components/CullTiles.js index fddc3679b..4246ce3aa 100644 --- a/v3/src/gameobjects/tilemap/components/CullTiles.js +++ b/v3/src/gameobjects/tilemap/components/CullTiles.js @@ -1,3 +1,12 @@ +/** + * Returns the tiles in the given layer that are within the camera's viewport. This is used + * internally. + * + * @param {LayerData} layer - [description] + * @param {Camera} camera - [description] + * @param {array} [outputArray] - [description] + * @returns {array} + */ var CullTiles = function (layer, camera, outputArray) { if (outputArray === undefined) { outputArray = []; } diff --git a/v3/src/gameobjects/tilemap/components/GetTilesWithinShape.js b/v3/src/gameobjects/tilemap/components/GetTilesWithinShape.js index d04673d75..abe016c8a 100644 --- a/v3/src/gameobjects/tilemap/components/GetTilesWithinShape.js +++ b/v3/src/gameobjects/tilemap/components/GetTilesWithinShape.js @@ -14,8 +14,8 @@ var TriangleToRectangle = function (triangle, rect) }; // Circle, Line, Rect, Triangle in world coordinates. -// Notes: circle is not working yet - see CircleToRectangle in geom. Could possibly be optimized -// by copying the shape and shifting it into tilemapLayer coordinates instead of shifting the tiles. +// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer +// coordinates instead of shifting the tiles. var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) { if (shape === undefined) { return []; }