2017-06-09 04:00:12 +00:00
|
|
|
var Class = require('../../../utils/Class');
|
2017-07-04 00:59:31 +00:00
|
|
|
var Components = require('../../components');
|
2017-11-09 18:18:23 +00:00
|
|
|
var DynamicTilemapLayerRender = require('./DynamicTilemapLayerRender');
|
2018-02-07 15:27:21 +00:00
|
|
|
var GameObject = require('../../GameObject');
|
2017-11-15 21:28:15 +00:00
|
|
|
var TilemapComponents = require('../components');
|
2017-06-09 04:00:12 +00:00
|
|
|
|
2018-02-07 15:27:21 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A
|
|
|
|
* DynamicTilemapLayer can only render tiles from a single tileset.
|
|
|
|
*
|
|
|
|
* A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a
|
|
|
|
* StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the
|
|
|
|
* tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those
|
|
|
|
* features.
|
|
|
|
*
|
|
|
|
* @class DynamicTilemapLayer
|
|
|
|
* @constructor
|
|
|
|
*
|
|
|
|
* @param {Scene} scene - [description]
|
|
|
|
* @param {Tilemap} tilemap - The Tilemap this layer is a part of.
|
|
|
|
* @param {integer} layerIndex - The index of the LayerData associated with this layer.
|
|
|
|
* @param {Tileset} tileset - The tileset used to render the tiles in this layer.
|
|
|
|
* @param {number} [x=0] - The world x position where the top left of this layer will be placed.
|
|
|
|
* @param {number} [y=0] - The world y position where the top left of this layer will be placed.
|
|
|
|
*/
|
2017-11-09 18:18:23 +00:00
|
|
|
var DynamicTilemapLayer = new Class({
|
2017-06-09 04:00:12 +00:00
|
|
|
|
|
|
|
Extends: GameObject,
|
|
|
|
|
|
|
|
Mixins: [
|
|
|
|
Components.Alpha,
|
|
|
|
Components.BlendMode,
|
2018-02-01 00:50:15 +00:00
|
|
|
Components.Depth,
|
2017-06-09 04:00:12 +00:00
|
|
|
Components.Flip,
|
|
|
|
Components.GetBounds,
|
|
|
|
Components.Origin,
|
2018-01-29 21:46:48 +00:00
|
|
|
Components.Pipeline,
|
2017-06-09 04:00:12 +00:00
|
|
|
Components.ScaleMode,
|
|
|
|
Components.Size,
|
|
|
|
Components.Transform,
|
|
|
|
Components.Visible,
|
2017-06-22 02:19:03 +00:00
|
|
|
Components.ScrollFactor,
|
2017-11-09 18:18:23 +00:00
|
|
|
DynamicTilemapLayerRender
|
2017-06-09 04:00:12 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-11-11 16:38:52 +00:00
|
|
|
function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y)
|
2017-06-09 04:00:12 +00:00
|
|
|
{
|
2017-11-09 18:18:23 +00:00
|
|
|
GameObject.call(this, scene, 'DynamicTilemapLayer');
|
2017-06-09 04:00:12 +00:00
|
|
|
|
2018-01-11 02:45:28 +00:00
|
|
|
/**
|
|
|
|
* Used internally by physics system to perform fast type checks.
|
|
|
|
* @property {boolean} isTilemap
|
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
this.isTilemap = true;
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* The Tilemap that this layer is a part of.
|
2018-01-25 13:29:43 +00:00
|
|
|
* @property {Tilemap} tilemap
|
2017-11-30 01:22:48 +00:00
|
|
|
*/
|
2018-01-25 13:29:43 +00:00
|
|
|
this.tilemap = tilemap;
|
2017-11-30 01:22:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The index of the LayerData associated with this layer.
|
|
|
|
* @property {integer} layerIndex
|
|
|
|
*/
|
2017-11-11 16:38:52 +00:00
|
|
|
this.layerIndex = layerIndex;
|
2017-11-30 01:22:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The LayerData associated with this layer. LayerData can only be associated with one
|
|
|
|
* tilemap layer.
|
|
|
|
* @property {LayerData} layerIndex
|
|
|
|
*/
|
2017-11-11 16:38:52 +00:00
|
|
|
this.layer = tilemap.layers[layerIndex];
|
2017-11-30 01:22:48 +00:00
|
|
|
this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer
|
2017-11-03 16:52:57 +00:00
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* The Tileset associated with this layer. A tilemap layer can only render from one Tileset.
|
|
|
|
* @property {Tileset} tileset
|
|
|
|
*/
|
|
|
|
this.tileset = tileset;
|
2017-11-17 01:55:17 +00:00
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* Used internally with the canvas render. This holds the tiles that are visible within the
|
|
|
|
* camera.
|
|
|
|
* @property {Tileset} culledTiles
|
|
|
|
*/
|
2017-06-09 04:00:12 +00:00
|
|
|
this.culledTiles = [];
|
2017-11-03 16:52:57 +00:00
|
|
|
|
2018-01-14 22:15:53 +00:00
|
|
|
this.setAlpha(this.layer.alpha);
|
2017-06-09 04:00:12 +00:00
|
|
|
this.setPosition(x, y);
|
|
|
|
this.setOrigin();
|
2017-11-29 18:52:34 +00:00
|
|
|
this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height);
|
2018-01-29 21:46:48 +00:00
|
|
|
this.initPipeline('TextureTintPipeline');
|
2017-06-09 04:00:12 +00:00
|
|
|
},
|
|
|
|
|
2018-01-29 22:30:57 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
|
|
|
calculateFacesAt: function (tileX, tileY)
|
|
|
|
{
|
|
|
|
TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-22 01:18:34 +00:00
|
|
|
calculateFacesWithin: function (tileX, tileY, width, height)
|
|
|
|
{
|
|
|
|
TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Sprite[]}
|
|
|
|
*/
|
2017-11-29 02:49:24 +00:00
|
|
|
createFromTiles: function (indexes, replacements, spriteConfig, scene, camera)
|
|
|
|
{
|
|
|
|
return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer);
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile[]}
|
|
|
|
*/
|
2017-11-14 21:35:18 +00:00
|
|
|
cull: function (camera)
|
2017-06-09 04:00:12 +00:00
|
|
|
{
|
2017-11-30 01:22:48 +00:00
|
|
|
return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles);
|
2017-11-15 19:50:56 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-26 14:58:38 +00:00
|
|
|
copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces)
|
2017-11-16 02:16:43 +00:00
|
|
|
{
|
2017-11-26 14:58:38 +00:00
|
|
|
TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer);
|
2017-11-16 02:16:43 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* Destroys this DynamicTilemapLayer and removes its link to the associated LayerData.
|
|
|
|
*
|
|
|
|
* @method Phaser.TilemapLayer#destroy
|
|
|
|
*/
|
2017-11-17 01:55:17 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
2017-11-29 17:36:36 +00:00
|
|
|
// Uninstall this layer only if it is still installed on the LayerData object
|
2017-11-30 01:22:48 +00:00
|
|
|
if (this.layer.tilemapLayer === this)
|
|
|
|
{
|
|
|
|
this.layer.tilemapLayer = undefined;
|
|
|
|
}
|
2018-01-25 13:29:43 +00:00
|
|
|
this.tilemap = undefined;
|
2017-11-17 01:55:17 +00:00
|
|
|
this.layer = undefined;
|
|
|
|
this.tileset = undefined;
|
|
|
|
this.culledTiles.length = 0;
|
|
|
|
GameObject.prototype.destroy.call(this);
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-26 15:19:57 +00:00
|
|
|
fill: function (index, tileX, tileY, width, height, recalculateFaces)
|
2017-11-16 02:16:43 +00:00
|
|
|
{
|
2017-11-26 15:19:57 +00:00
|
|
|
TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer);
|
2017-11-16 02:16:43 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile[]}
|
|
|
|
*/
|
2017-11-29 02:49:24 +00:00
|
|
|
filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions)
|
|
|
|
{
|
|
|
|
return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer);
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile}
|
|
|
|
*/
|
2017-11-17 01:08:58 +00:00
|
|
|
findByIndex: function (findIndex, skip, reverse)
|
|
|
|
{
|
|
|
|
return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer);
|
|
|
|
},
|
|
|
|
|
2017-12-01 19:46:27 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile|null}
|
|
|
|
*/
|
|
|
|
findTile: function (callback, context, tileX, tileY, width, height, filteringOptions)
|
|
|
|
{
|
|
|
|
return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer);
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-26 00:03:21 +00:00
|
|
|
forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions)
|
2017-11-15 22:36:41 +00:00
|
|
|
{
|
2017-11-26 00:03:21 +00:00
|
|
|
TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer);
|
2017-11-16 02:16:43 +00:00
|
|
|
return this;
|
2017-11-15 22:36:41 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile}
|
|
|
|
*/
|
2017-11-15 21:28:15 +00:00
|
|
|
getTileAt: function (tileX, tileY, nonNull)
|
2017-11-15 19:50:56 +00:00
|
|
|
{
|
2017-11-16 19:09:07 +00:00
|
|
|
return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer);
|
2017-11-15 21:28:15 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile}
|
|
|
|
*/
|
2017-11-17 13:58:33 +00:00
|
|
|
getTileAtWorldXY: function (worldX, worldY, nonNull, camera)
|
2017-11-16 19:27:52 +00:00
|
|
|
{
|
2017-11-17 13:58:33 +00:00
|
|
|
return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer);
|
2017-11-16 19:27:52 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile[]}
|
|
|
|
*/
|
2017-11-26 00:03:21 +00:00
|
|
|
getTilesWithin: function (tileX, tileY, width, height, filteringOptions)
|
2017-11-15 22:36:41 +00:00
|
|
|
{
|
2017-11-26 00:03:21 +00:00
|
|
|
return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer);
|
2017-11-15 22:36:41 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile[]}
|
|
|
|
*/
|
2017-11-26 13:55:44 +00:00
|
|
|
getTilesWithinShape: function (shape, filteringOptions, camera)
|
|
|
|
{
|
|
|
|
return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer);
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile[]}
|
|
|
|
*/
|
2017-11-26 00:03:21 +00:00
|
|
|
getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera)
|
2017-11-25 14:42:19 +00:00
|
|
|
{
|
2017-11-26 00:03:21 +00:00
|
|
|
return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer);
|
2017-11-25 14:42:19 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
2017-11-15 21:28:15 +00:00
|
|
|
hasTileAt: function (tileX, tileY)
|
|
|
|
{
|
|
|
|
return TilemapComponents.HasTileAt(tileX, tileY, this.layer);
|
2017-11-16 02:16:43 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
2017-11-17 13:58:33 +00:00
|
|
|
hasTileAtWorldXY: function (worldX, worldY, camera)
|
|
|
|
{
|
|
|
|
return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer);
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile}
|
|
|
|
*/
|
2017-11-22 01:18:34 +00:00
|
|
|
putTileAt: function (tile, tileX, tileY, recalculateFaces)
|
2017-11-16 19:09:07 +00:00
|
|
|
{
|
2017-11-22 01:18:34 +00:00
|
|
|
return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer);
|
2017-11-16 19:09:07 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile}
|
|
|
|
*/
|
2017-11-22 01:18:34 +00:00
|
|
|
putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera)
|
2017-11-17 13:58:33 +00:00
|
|
|
{
|
2017-11-22 01:18:34 +00:00
|
|
|
return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer);
|
2017-11-17 13:58:33 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 03:59:11 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
|
|
|
putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces)
|
|
|
|
{
|
|
|
|
TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-29 19:22:30 +00:00
|
|
|
randomize: function (tileX, tileY, width, height, indexes)
|
2017-11-16 02:16:43 +00:00
|
|
|
{
|
2017-11-29 19:22:30 +00:00
|
|
|
TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer);
|
2017-11-16 02:16:43 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile}
|
|
|
|
*/
|
2017-11-22 01:18:34 +00:00
|
|
|
removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces)
|
2017-11-16 19:09:07 +00:00
|
|
|
{
|
2017-11-22 01:18:34 +00:00
|
|
|
return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer);
|
2017-11-16 19:09:07 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Tile}
|
|
|
|
*/
|
2017-11-22 01:18:34 +00:00
|
|
|
removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera)
|
2017-11-17 13:58:33 +00:00
|
|
|
{
|
2017-11-22 01:18:34 +00:00
|
|
|
return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer);
|
2017-11-17 13:58:33 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-29 15:05:53 +00:00
|
|
|
renderDebug: function (graphics, styleConfig)
|
|
|
|
{
|
|
|
|
TilemapComponents.RenderDebug(graphics, styleConfig, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-17 01:08:58 +00:00
|
|
|
replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height)
|
|
|
|
{
|
|
|
|
TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-21 02:06:49 +00:00
|
|
|
setCollision: function (indexes, collides, recalculateFaces)
|
|
|
|
{
|
|
|
|
TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-21 02:06:49 +00:00
|
|
|
setCollisionBetween: function (start, stop, collides, recalculateFaces)
|
|
|
|
{
|
|
|
|
TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-01-23 15:05:37 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
|
|
|
setCollisionByProperty: function (properties, collides, recalculateFaces)
|
|
|
|
{
|
|
|
|
TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-21 02:06:49 +00:00
|
|
|
setCollisionByExclusion: function (indexes, collides, recalculateFaces)
|
|
|
|
{
|
|
|
|
TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-01-23 15:40:59 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
|
|
|
setCollisionFromCollisionGroup: function (collides, recalculateFaces)
|
|
|
|
{
|
|
|
|
TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-29 13:53:04 +00:00
|
|
|
setTileIndexCallback: function (indexes, callback, callbackContext)
|
|
|
|
{
|
|
|
|
TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-29 14:20:24 +00:00
|
|
|
setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext)
|
|
|
|
{
|
|
|
|
TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-16 02:16:43 +00:00
|
|
|
shuffle: function (tileX, tileY, width, height)
|
|
|
|
{
|
|
|
|
TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer);
|
|
|
|
return this;
|
2017-11-17 01:08:58 +00:00
|
|
|
},
|
2017-06-22 02:19:03 +00:00
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
2017-11-17 01:08:58 +00:00
|
|
|
swapByIndex: function (indexA, indexB, tileX, tileY, width, height)
|
|
|
|
{
|
|
|
|
TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer);
|
|
|
|
return this;
|
2017-11-17 02:36:45 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 15:22:54 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {number}
|
|
|
|
*/
|
|
|
|
tileToWorldX: function (tileX, camera)
|
|
|
|
{
|
|
|
|
return TilemapComponents.TileToWorldX(tileX, camera, this.layer);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {number}
|
|
|
|
*/
|
|
|
|
tileToWorldY: function (tileY, camera)
|
|
|
|
{
|
|
|
|
return TilemapComponents.TileToWorldY(tileY, camera, this.layer);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Vector2}
|
|
|
|
*/
|
|
|
|
tileToWorldXY: function (tileX, tileY, point, camera)
|
|
|
|
{
|
|
|
|
return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer);
|
|
|
|
},
|
|
|
|
|
2017-12-03 14:56:12 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {this}
|
|
|
|
*/
|
|
|
|
weightedRandomize: function (tileX, tileY, width, height, weightedIndexes)
|
|
|
|
{
|
|
|
|
TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {number}
|
|
|
|
*/
|
2017-11-25 13:08:06 +00:00
|
|
|
worldToTileX: function (worldX, snapToFloor, camera)
|
2017-11-17 02:36:45 +00:00
|
|
|
{
|
2017-11-25 13:08:06 +00:00
|
|
|
return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer);
|
2017-11-17 02:36:45 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {number}
|
|
|
|
*/
|
2017-11-25 13:08:06 +00:00
|
|
|
worldToTileY: function (worldY, snapToFloor, camera)
|
2017-11-17 02:36:45 +00:00
|
|
|
{
|
2017-11-25 13:08:06 +00:00
|
|
|
return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer);
|
2017-11-17 02:36:45 +00:00
|
|
|
},
|
|
|
|
|
2017-11-30 01:22:48 +00:00
|
|
|
/**
|
|
|
|
* See component documentation.
|
|
|
|
*
|
|
|
|
* @return {Vector}
|
|
|
|
*/
|
2017-11-25 13:08:06 +00:00
|
|
|
worldToTileXY: function (worldX, worldY, snapToFloor, point, camera)
|
2017-11-17 02:36:45 +00:00
|
|
|
{
|
2017-11-25 13:08:06 +00:00
|
|
|
return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer);
|
2017-11-17 01:08:58 +00:00
|
|
|
}
|
2017-06-09 04:00:12 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-11-09 18:18:23 +00:00
|
|
|
module.exports = DynamicTilemapLayer;
|