パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.12.0

tiled

Dart Tiled ライブラリ。TMX ファイルを有用な表現に変換します。Flame と互換性があります。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.5万
いいね数
33
Pub ポイント
150

パッケージをインストール

flutter pub add tiled

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Tiled パッケージは、Tiled マップエディタから出力される TMX ファイルを解析し、ゲーム開発で利用可能な構造化データに変換するための Dart ライブラリです。Flame ゲームエンジンとシームレスに統合されており、複数のプラットフォーム上でタイルマップを効率的に読み込み、レンダリングできるようにします。レイヤー、オブジェクト、タイルセットなどのさまざまな Tiled 機能をサポートしており、2D ゲームに最適です。明確で直感的な API を備えており、手動でのデータ処理なしにマップの統合を簡単に実現できます。

用途

  • ゲームで2Dタイルマップを読み込む
  • Tiled マップを Flame エンジンと統合する
  • レイヤードゲームレベルのレンダリング
  • TMX ファイルからの衝突オブジェクトの処理
  • プラットフォームゲームやパズルゲームの構築

主な機能

  • TMX ファイルの解析をサポートしています
  • Flameゲームエンジンと互換性があります
  • クロスプラットフォーム対応
  • タイルセットとレイヤーを処理します
  • オブジェクトおよび衝突データを提供します

適している対象

  • Flame を使用する 2D ゲーム開発者
  • TiledマップユーザーがDart統合を求めています
  • クロスプラットフォームゲームプロジェクト
  • インディーゲームクリエイター
  • ゲームプロトタイピング

注意事項

  • Tiledマップファイル(TMX形式)が必要です
  • 2Dタイルマップの利用ケースに限定
  • 完全なレンダリングには Flame に依存します
  • カスタムTiledプラグインの直接サポートなし

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Tiled Dart

Pub cicd Discord

A Dart Tiled library.

Install from Dart Pub Repository

To include the package as a dependency in your pubspec.yaml, run the following (or add it manually):

dart pub add tiled

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 TiledMap.parseTmx():

    final String tmxBody = /* ... */;
    final TiledMap mapTmx = TiledMap.parseTmx(tmxBody);
Load Json Files

Alternatively load a json file with TiledMap.parseJson():

    final String jsonBody = /* ... */;
    final TiledMap mapJson = TiledMap.parseJson(jsonBody);
External Files

If your map references external files, like external tilesets (.tsx) or object templates (.tx), you have to pass one or more ParserProviders that resolve these files. Every time the parser encounters a reference to an external file, the first provider that canProvide the referenced path is asked for a Parser of its contents through getSource.

The path is always relative to the map file, also for files referenced from other external files, so a single provider can resolve any number of files, for example everything below a directory:

class DirectoryProvider extends ParserProvider {
  final String root;

  DirectoryProvider(this.root);

  @override
  bool canProvide(String path) => File('$root/$path').existsSync();

  @override
  Parser getSource(String path) {
    return Parser.fromString(File('$root/$path').readAsStringSync());
  }
}

Parser.fromString creates an XmlParser or a JsonParser depending on the contents. Every file is requested at most once per parsed map.

Objects that use a template inherit every value they do not specify themselves from the object of the template, and their gid is translated to the tilesets of the map. When the map does not contain the tileset of the template it is added to TiledMap.tilesets, like Tiled does when loading the map.

The providers are passed to parseTmx or parseJson:

    final TiledMap mapTmx = TiledMap.parseTmx(
      tmxBody,
      providers: [DirectoryProvider('assets/tiles')],
    );
Loading External Files Asynchronously

When the external files can only be loaded asynchronously, for example from an asset bundle, use TiledMap.fromString instead. It parses either tmx or json and loads every referenced file, also the ones referenced from other external files, with the given loader before returning the map:

    final TiledMap map = await TiledMap.fromString(
      contents,
      (path) => rootBundle.loadString('assets/tiles/$path'),
    );
Implementation

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

カテゴリー

依存関係

依存関係一覧 4 件

ソースリポジトリ

このパッケージを使用しているプロジェクト