Skip to content

A Dart Tiled library. Parse your TMX files into useful representations. Compatible with Flame.

License

Notifications You must be signed in to change notification settings

supagu/tiled.dart

This branch is 49 commits behind flame-engine/tiled.dart:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

65e60de · May 24, 2021
May 24, 2021
May 24, 2021
May 24, 2021
May 24, 2021
May 24, 2021
May 24, 2021
Jan 1, 2014
May 24, 2021
May 24, 2021
May 24, 2021

Repository files navigation

Tiled Dart

Pub cicd Discord

A Dart Tiled library.

Install from Dart Pub Repository

Include the following in your pubspec.yaml:

    dependencies:
      tiled: 0.7.0

Usage

Import the package like this:

    import 'package:tiled/tiled.dart'

Load Tmx Files

Load a TMX file into a string by any means, and then pass the string to TileMapParser.parseXml():

    final String tmxBody = /* ... */;
    final TiledMap mapTmx = TileMapParser.parseTmx(tmxBody);

If your tmx file includes a external tsx reference, you have to add a CustomParser

class CustomTsxProvider extends TsxProvider {
  @override
  Parser getSource(String fileName) {
    final xml = File(fileName).readAsStringSync();
    final node = XmlDocument.parse(xml).rootElement;
    return XmlParser(node);
  }
}

And use it in the parseTmx method

    final String tmxBody = /* ... */;
    final TiledMap mapTmx = TileMapParser.parseTmx(tmxBody, tsx: CustomTsxProvider());

Load Json Files

Alternatively load a json file.

    final String jsonBody = /* ... */;
    final TiledMap mapTmx = TileMapParser.parseJson(jsonBody);

Implementation

For further information and more usage examples, please take a look at the examples in flame_tiled.

About

A Dart Tiled library. Parse your TMX files into useful representations. Compatible with Flame.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 97.0%
  • Shell 3.0%