Skip to content

TileMap.createFromTiles doesn't properly handle multiple tilesets #7122

Closed

Description

@vikerman

Version

  • Phaser Version: 3.88.2

Description

Tilemap.createFromTiles with useSpriteSheet specified in the SpriteConfig assigns the frame number just using the current tile index without taking into account that the tile index doesn't always start from 1 for all tilesets other than the very first one.

Example Test Code

https://stackblitz.com/~/github.com/vikerman/my-phaser-game

The sprites created from the second tileset are all wrong
Image

To test the fix locally comment lines 221-230 and uncomment lines 233-242 in Game.ts in the StackBlitz .

Sprites are properly created after the fix

Image

Additional Information

The line at

config.frame = tile.index - 1;

            config.frame = tile.index - 1;

needs to be changed to

             config.frame = tile.index - tile.tileset.firstgid;

Tested the fix locally by creating a secondary copy of createFromTiles in my project and applying the above fix.

Activity

  1. added a commit that references this issue on Apr 26, 2025
    b7fe458
  2. locked as resolved and limited conversation to collaborators on Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions