Skip to content

Tilemap collision boundaries not moved when moving tilemap #3494

@Ribosom

Description

@Ribosom

Steps to Reproduce

  1. Create a Tilemap
  2. Set a cell to solid
  3. Move the pos of the Tilemap

Same problem appears, in other order

  1. Create a Tilemap
  2. Move the pos of the Tilemap
  3. Set a cell to solid

only when setting the pos directly on construction it doesn't fail.

Expected Result

Collision boundaries are moved also, when Tilemap (and its graphics) are moved.

Actual Result

Collision boundaries are not moved.

Environment

  • Browser: Firefox 141.0
  • Excalibur versions: 0.30.3
  • Operating system: Windows

Additional information

This problem also occurs when using useLevelOffsets: false with the LDtk plugin and having World Coordinates != 0,0 - as a direct result of this bug (because in the plugin the pos is changed after construction).

Minimal code

game.start('start', {
  loader,
}).then(() => {

  const spriteSheet = SpriteSheet.fromImageSource({
    image: Resources.TileMap,
    grid: {
      rows: 4,
      columns: 4,
      spriteHeight: 32,
      spriteWidth: 32
    },
    spacing: {
      margin: {
        x: 0,
        y: 0
      }
    }
  });

  const tilemap = new TileMap({
    rows: 4,
    columns: 4,
    tileWidth: 32,
    tileHeight: 32,
  });
  let tile1 = tilemap.getTile(0, 0);
  if (tile1) {
    tile1.solid = true // XXX first relevant line
  }

  for (let tile of tilemap.tiles) {
    const sprite = spriteSheet.getSprite(0, 0);
    if (sprite) {
      tile.addGraphic(sprite);
    }
  }

  tilemap.pos = tilemap.pos.add(vec(512, 0)) // XXX second relevant line

  game.currentScene.add(tilemap)
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleThis issue or PR has not had any activity recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions