Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tilemaps/TilemapLayerWebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var TilemapLayerWebGLRenderer = function (renderer, src, drawingContext, parentM
continue;
}

var tileIndex = tileset.getAnimatedTileId(tile.index, timeElapsed);
var tileIndex = tileset.getAnimatedTileId(tile.index, tileset.animating ? timeElapsed : 0);

if (tileIndex === null)
{
Expand Down
11 changes: 11 additions & 0 deletions src/tilemaps/Tileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ var Tileset = new Class({
*/
this.texCoordinates = [];


/**
* Whether the tileset animations should play or not. If false, animated tiles will stay on their first frame.
*
* @name Phaser.Tilemaps.Tileset#animating
* @type {boolean}
* @since 4.2.0
* @default true
*/
this.animating = true;

/**
* The number of frames above which a tile is considered to have
* many animation frames. This is used to optimize rendering.
Expand Down
1 change: 1 addition & 0 deletions tests/tilemaps/Tileset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Tileset', function ()
expect(ts.columns).toBe(0);
expect(ts.total).toBe(0);
expect(ts.texCoordinates).toEqual([]);
expect(ts.animating).toBe(true);
expect(ts.animationSearchThreshold).toBe(64);
expect(ts.maxAnimationLength).toBe(0);
});
Expand Down
20 changes: 15 additions & 5 deletions types/phaser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130528,7 +130528,8 @@ declare namespace Phaser {
* @param y The y coordinate of the pixel within the Texture.
* @param key The unique string-based key of the Texture.
* @param frame The string or index of the Frame.
* @returns A Color object populated with the color values of the requested pixel,or `null` if the coordinates were out of bounds.
* @returns A Color object populated with the color values of the requested pixel,
or `null` if the coordinates were out of bounds.
*/
getPixel(x: number, y: number, key: string, frame?: string | number): Phaser.Display.Color | null;

Expand Down Expand Up @@ -131924,7 +131925,8 @@ declare namespace Phaser {
* GID this set will use here. Default 0.
* @param tileOffset Tile texture drawing offset.
* If not specified, it will default to {0, 0} Default {x: 0, y: 0}.
* @returns Returns the Tileset object that was created or updated, or null if itfailed.
* @returns Returns the Tileset object that was created or updated, or null if it
failed.
*/
addTilesetImage(tilesetName: string, key?: string, tileWidth?: number, tileHeight?: number, tileMargin?: number, tileSpacing?: number, gid?: number, tileOffset?: object): Phaser.Tilemaps.Tileset | null;

Expand Down Expand Up @@ -137770,6 +137772,11 @@ declare namespace Phaser {
*/
readonly texCoordinates: object[];

/**
* Whether the tileset animations should play or not. If false, animated tiles will stay on their first frame.
*/
animating: boolean;

/**
* The number of frames above which a tile is considered to have
* many animation frames. This is used to optimize rendering.
Expand Down Expand Up @@ -137833,7 +137840,8 @@ declare namespace Phaser {
* Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index.
* Returns null if tile index is not contained in this Tileset.
* @param tileIndex The unique id of the tile across all tilesets in the map.
* @returns Object in the form { x, y } representing the top-left UV coordinatewithin the Tileset image.
* @returns Object in the form { x, y } representing the top-left UV coordinate
within the Tileset image.
*/
getTileTextureCoordinates(tileIndex: number): object | null;

Expand Down Expand Up @@ -139243,7 +139251,8 @@ declare namespace Phaser {
* @param insertNull Controls how empty tiles (those with an index of -1) are stored in
* the LayerData. If `true`, empty tile positions are stored as `null`. If `false`, a Tile object
* with an index of -1 is created for each empty position instead.
* @returns - An array of LayerData objects, one for each entry injson.layer.
* @returns - An array of LayerData objects, one for each entry in
json.layer.
*/
function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[];

Expand Down Expand Up @@ -139412,7 +139421,8 @@ declare namespace Phaser {
* @param json The Tiled JSON object.
* @param insertNull Controls how empty tiles, tiles with an index of -1, in the map
* data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}).
* @returns - An array of LayerData objects, one for each entry injson.layers with the type 'tilelayer'.
* @returns - An array of LayerData objects, one for each entry in
json.layers with the type 'tilelayer'.
*/
function ParseTileLayers(json: object, insertNull: boolean): Phaser.Tilemaps.LayerData[];

Expand Down