Skip to content

Use first item of an array of tilesets when making a TilemapGPULayer #7163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2025
Merged
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
11 changes: 10 additions & 1 deletion src/tilemaps/Tilemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ var Tilemap = new Class({
* @since 3.0.0
*
* @param {(number|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 {(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. When this is an array, if `gpu` is `true`, only the first element in the array is used as the tileset.
* @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.
* @param {boolean} [gpu=false] - Create a TilemapGPULayer instead of a TilemapLayer. This option is WebGL-only. A TilemapGPULayer is less flexible, but can be much faster.
Expand Down Expand Up @@ -637,6 +637,15 @@ var Tilemap = new Class({

if (gpu)
{
if (Array.isArray(tileset))
{
if (tileset.length > 1)
{
console.warn('TilemapGPULayer can only use one tileset. Using the first item given.');
}
tileset = tileset[0];
}

layer = new TilemapGPULayer(this.scene, this, index, tileset, x, y);
}
else
Expand Down