ASGAlex / flame_tiled_utils

A set of useful utils to extend tiled functionality
MIT License
8 stars 3 forks source link

Positional data for Isometric maps #7

Open tviel opened 3 months ago

tviel commented 3 months ago

Generating an isometric map with tiled and exporting it. Loading of the tiled map file and adding itself as a component shows the expected result. However, using the TileProcessor.processTileType and taking the position results in non-isometrical aligned sprites.

The isometric map in tiled (4 tiles placed in a tile layer): image

The loaded tmx in flutter / flame:

Here the used code for loading and adding the map and tiles


Future<void> _loadWorldForChallenge() async {
    _mapComponent =
        await TiledComponent.load('challenges_1.tmx', Vector2(64, 32));

    add(_mapComponent);

    TileProcessor.processTileType(
        tileMap: _mapComponent.tileMap,
        processorByType: <String, TileProcessorFunc>{
          'region': ((tile, position, size) async {
            final sprite = await tile.getSprite();
            add(
              SpriteComponent(
                  sprite: sprite, position: position, size: Vector2(384, 208)),
            );
          }),
        },
        layersToLoad: [
          'regions',
        ]);
  }

Is the package ready for isometric maps from tiled?

ASGAlex commented 3 months ago

Hi!

Is the package ready for isometric maps from tiled?

No, I had never tested it with such use-case. It seems that you need:

  1. to perform position conversion manually
  2. to scale & rotate the sprite itself

The library does not check what kind of map you using, it just hooks into loaded tiled map and allows you to manipulate with raw data. So, it seems that isometric maps needs some additional work to be supported "out of the box"...