DEKI/ENGINE ドキュメント
マニュアル API リファレンス
deki-tiledmapeditor-integration 0.40.1
Deki パッケージリファレンス
deki-tiledmapeditor-integration

Tiled Map Editor との連携。.tmj ファイルをプロジェクトに置くと、エディターがストリーミング可能なバイナリのタイルマップにベイクします。

リポジトリ: github.com/dekiengine/deki-tiledmapeditor-integration · 最新リリース: 0.40.0 · エンジン 0.40.0 以降が必要 · 依存: deki-2d, deki-rendering

DekiEditor --packages-add deki-tiledmapeditor-integration <project> か、パッケージマネージャーからインストールします。エンジン自身のコンポーネントと C++ API は Deki のドキュメントにあります。

エディターでは Tiled Map Editor Integration と表示されます。

コンポーネント

コンポーネント カテゴリ 説明
TilemapColliderComponent タイルマップ タイルマップのレイヤーにあるタイルごとの衝突形状を、クエリで使えるようにします。
TilemapComponent タイルマップ Tiled のマップを描きます。カメラの周りのチャンクを順次読み込みます。
TilemapObjectSpawner タイルマップ シーンの読み込み時に、Tiled マップのオブジェクトレイヤーからオブジェクトを生成します。

機能フラグ

ビルドから外せる部分です。define を持つ機能はその define で切り替わり、それ以外はコンポーネントと一緒に取り除かれます。

機能 define デフォルト
Tilemap Rendering DEKI_FEATURE_TILEMAP_RENDER オン
Tilemap Collision DEKI_FEATURE_TILEMAP_COLLISION オン
Object Layers DEKI_FEATURE_TILEMAP_OBJECTS オン

コンポーネントリファレンス

TilemapColliderComponent

タイルマップのレイヤーにあるタイルごとの衝突形状を、クエリで使えるようにします。

インスペクターでの名前: タイルマップコライダーコンポーネント · カテゴリ: タイルマップ · 型: DekiTiledMap::TilemapColliderComponent

プロパティ 型 デフォルト 制約 説明
tilemap AssetRef (Tilemap) "" タイルを当たり判定にするマップです。
collisionLayer int32 0 マップのどのレイヤーに衝突用のタイルがあるかです。そのレイヤーにタイルがあるマスは通れず、空のマスは通れます。
loopX bool false ループするマップに合わせて、当たり判定を横方向に繰り返します。
wrapPeriodX int32 0 loopX が許すときに表示 横方向の 1 回分の繰り返しの幅 (タイル数) です。0 ではマップ自体の幅を使います。
loopY bool false 当たり判定を縦方向に繰り返します。
wrapPeriodY int32 0 loopY が許すときに表示 縦方向の 1 回分の繰り返しの高さ (タイル数) です。0 ではマップ自体の高さを使います。

TilemapComponent

Tiled のマップを描きます。カメラの周りのチャンクを順次読み込みます。

インスペクターでの名前: タイルマップコンポーネント · カテゴリ: タイルマップ · 型: DekiTiledMap::TilemapComponent

プロパティ 型 デフォルト 制約 説明
tilemap AssetRef (Tilemap) "" Tiled から書き出したマップです。
visibleLayerMask int32 2147483647 マップのどのレイヤーを描くかを、レイヤーごとに 1 ビットで指定します。すべてのビットを立てるとすべて描きます。
chunkPadding int32 1 画面の端の外側で、読み込んで描いておくチャンクの数です。少し余白があると、スクロール中に端でタイルが突然現れるのを防げます。
chunkCacheKiB int32 256 16 から 262144 このマップがデコード済みのチャンクを保持できるメモリ量 (KiB) です。上限を超えると最も長く描かれていないチャンクから捨てられ、必要になったときにストレージから読み直します。そのため小さすぎると、何かが欠けるのではなく、スクロール中のカクつきとして現れます。ESP32 には 256 が向いており、デスクトップならずっと多く使えます。
tintColor Color "#FFFFFFFF" すべてのタイルに乗算します。白ならマップはそのままです。
pixelsPerMeter float 16 1 から 256 マップの何ピクセルで 1 メートルになるかです。これでマップとシーン内のほかのものの位置が揃います。
loopX bool false マップを横方向に繰り返し、端を越えてスクロールすると反対側につながります。
wrapPeriodX int32 0 loopX が許すときに表示 横方向の 1 回分の繰り返しの幅 (タイル数) です。0 ではマップ自体の幅を使います。
loopY bool false マップを縦方向に繰り返します。
wrapPeriodY int32 0 loopY が許すときに表示 縦方向の 1 回分の繰り返しの高さ (タイル数) です。0 ではマップ自体の高さを使います。

sortingOrder, ignoreClip, pixelSnap, alphaMode を RendererComponent から継承します。

TilemapObjectSpawner

シーンの読み込み時に、Tiled マップのオブジェクトレイヤーからオブジェクトを生成します。

インスペクターでの名前: タイルマップのオブジェクト生成 · カテゴリ: タイルマップ · 型: DekiTiledMap::TilemapObjectSpawner

プロパティ 型 デフォルト 制約 説明
tilemap AssetRef (Tilemap) "" オブジェクトレイヤーを読み込むマップです。Tiled で配置した各オブジェクトがシーンのオブジェクトになります。
pixelsPerMeter float 16 1 から 256 マップの何ピクセルで 1 メートルになるかです。これで生成したオブジェクトが Tiled で置いた位置に来ます。
sortBase int32 0 ワールドの水平線 (Y 0) に立つタイルオブジェクトの描画順です。
sortPerMeter int32 0 タイルオブジェクトの位置が 1 メートル下がるごとに、描画順をどれだけ上げるかです。0 より大きいと画面の下にあるものほど手前に描かれ、キャラクターが物の後ろを歩けます。1 メートルあたりのピクセル数と同じ値にするとピクセル行ごとに 1 つ描画順が上がり、Tiled エディターと同じようにオブジェクトが重なります。0 ではすべてのタイルオブジェクトが基準の描画順になります。

変更履歴

変更履歴は英語です。

0.40.0

Fixed

  • A map under a camera that is not a number, or very far out, draws nothing. Its chunk range wrapped round and Tilemap::QueryVisibleChunks read past the end of its index, which crashed. A range with its ends the wrong way round now returns no chunks.

Changed

  • minEngine 0.40.0: built against engine 0.40.0. A build of this package from before does not load and is rebuilt.
  • The view copy works with a Pixel Perfect camera on screen pixels. A map drawn at 2x or more is still drawn from its copy when the camera's Pixel Grid is Screen, and scrolls a screen pixel at a time.

Added

  • The view copy works on ARGB8888 screens and at 2x, 3x... The copy a map is drawn into once, and copied from while the camera scrolls, was only made for RGB565 screens at 1:1, so a map on an ARGB8888 screen, or drawn larger under Pixel Perfect, was drawn tile by tile every frame. On ARGB8888 it is kept in the screen's format and copied row by row, where the map is the first thing drawn; under Pixel Perfect at a whole scale its tiles land on the same art-pixel grid as on screen. Nothing to set, and the same pixels: frames rendered both ways match. On the Anbernic RG40XX H (640x480, a four-layer isometric farm at 2x) the map went from 13 ms a frame to 2.6. The log says once when a map is drawn from a copy.
  • The map's render pass names itself "Tilemap" in the profiler's breakdown by object (RenderPass::Name).
  • Isometric maps. Set the map's orientation to Isometric in Tiled and it draws as diamonds, back to front across chunks, with tall tiles standing on their squares. Only chunks in view are loaded. Collision and spawned objects follow the same layout.
  • Tile objects placed in Tiled now appear. TilemapObjectSpawner gives each one a sprite of its tile, standing where Tiled draws it, with its flips, size and rotation. Sort Base and Sort Per Meter set its Sorting Order from where its point stands, so what stands lower on the screen can draw on top. A Tile Offset moves the picture without changing the order.
  • Tilemap::FindProperty, which finds one of an object's custom properties by name.
  • Tilesets with a margin or spacing. These were read as if they had none, which showed the wrong part of the image.
  • A tileset's Tile Offset and Object Alignment.
  • Group layers. Their layers used to be left out.
  • A layer's opacity, tint, offset and parallax, and a group's, drawn as in Tiled. An object layer's opacity, tint and offset apply to its objects.
  • Image layers, with their repeat across and down.
  • Animated tiles play, in tile layers and as tile objects, on one clock as in Tiled.
  • Tile and image layers above an object layer draw above its objects, as Tiled stacks them: the spawner draws them from components of their own.
  • Staggered and hexagonal maps, with either stagger axis and index and a hex side length, laid out and drawn in Tiled's order. Collision, spawned objects and Tilemap::PixelsToTile follow the same layout; Tilemap::Stagger() gives the grid.
  • A tileset's Tile Render Size set to Map Grid Size, with Fill Mode Stretch or Preserve Aspect Fit: its tiles are drawn at the map's tile size in tile layers.
  • Layer blend modes (Add, Multiply, Screen, Overlay, Darken, Lighten, Color Dodge, Color Burn, Hard Light, Soft Light, Difference, Exclusion) on tile and image layers, a group's too, blended as Tiled blends them. A blended layer costs two extra draws and a blend for each of its tiles. An object layer's blend mode is not drawn, and baking says so.
  • An object layer's parallax: its spawned objects go in an object named after the layer, which moves with the view before each frame as Tiled moves the layer.

Changed

  • A map that scrolls with the camera works out its copy once a frame. A frame redrawn in parts asked the map to draw once for each part, and each time the map found its layers, tilesets, box and copy again; now the frame's first part records what it found and the others only copy their pixels. With 16 sprites moving over the map on a LilyGO T-Deck that was about 15 parts a frame.- Tile layers draw faster, with the same pixels. Each tile gets the runs a sprite gets: its rows' transparent runs are skipped unread and its runs of one colour are filled. Only the cells that can reach the frame (or the strip being drawn) are walked. The tables they need live in external memory, so a board's internal RAM stays for its display and frame. On a LilyGO T-Deck at 320x240, a whole frame of an isometric map went from 34 to 24 ms, a staggered one from 38 to 25 ms and the "Your first game" farm from 38 to 33 ms. A layer with a blend mode draws in about half the time it first did. With the project's redrawChanges on, a map follows a camera that scrolls by whole pixels: only the edge it uncovers is drawn, and the same three maps hold 60 fps (16.6 ms, the display's own rate). That needs the map at the project's pixels per meter, on whole pixels, with parallax 1 and whole layer offsets; any other map redraws the whole frame as before. A layer walks only the cells its own tiles can reach the drawn area from, so a map's tall building tiles no longer widen the walk of its ground (the guide's farm: about 5200 cells walked a frame down to 900), and chunks asked for once in a frame are not asked for again by its later parts.
  • A map that scrolls with the camera keeps a copy of its pixels. Each group of layers a map draws together is kept, as drawn, in a buffer a margin larger than the view, in external memory. While the camera moves by whole pixels a frame, or each part redrawn of one, copies the map from there instead of drawing every layer's tiles again, and only what comes into view is drawn, a band at a time, at most one band piece a frame. Where the map is the first thing drawn, the copy holds it over the clear colour and the clear is skipped. The pixels are the ones drawing gives, checked pixel for pixel against drawing on a LilyGO T-Deck over every bench map. On the T-Deck the "Your first game" farm went from 31.7 to about 22.5 ms a frame with the camera following the farmer, and from 53.6 to 34.5 ms with 16 villagers walking. A layer group is drawn as before, every frame, when it has a tint, opacity, blend mode or parallax, animated tiles, tiles with partly see-through pixels, or a map scaled from its pixels per meter, in frames drawn in strips, on a GPU or not in RGB565, with the camera between pixels, and when there is no memory for the copy (about 190 KB at 320x240). A map draws nothing in the parts of a frame away from all its tiles.
  • An isometric map used to be drawn as a square grid and now draws correctly. One baked before this keeps the old layout until its .tmj is saved again.
  • Object positions and sizes keep Tiled's fractions (DTilemapObject::x, y, width and height are floats). They were rounded down to whole pixels, so an object at 10.5 now lands half a pixel further on. Maps are baked as file version 3; versions 1 and 2 still load, as whole pixels.
  • Objects spawned from a Tiled map keep the rotation drawn in Tiled, now that the engine draws positive rotation counter-clockwise (deki-rendering).
  • On an isometric map, tiles wider than the grid line up with the left corner of their square, as in Tiled.
  • A layer hidden in Tiled is no longer drawn, and collision can still read it. It used to be drawn. Show the layer in Tiled to keep it on screen.
  • On a square map, tiles taller than the grid stand on the bottom of their cell, as in Tiled. They used to hang down from its top.
  • On a square map, spawned objects land where Tiled shows them: relative to the map's centre, with Y up. They used to be off by the map's size and upside down, so anything placed to make up for that needs moving back.
  • A tile object used to spawn as an empty object and now also has a sprite, unless it is hidden in Tiled.
  • A tileset baked before this keeps ignoring its margin and spacing until its .tsj is saved again.
  • Spawned objects go into an object named "<owner> objects" beside the spawner's object, not under it. Under an object that draws the map they were drawn with it, so a character could never walk behind them. Code that looked for them among the map object's children needs to look there.
  • A map baked before this draws without its layers' opacity, tint, offsets, parallax and image layers until its .tmj is saved again (file version 2).
  • Sort Per Meter orders are floored, so each step is one order around 0 too, where they used to be cut toward 0 and the two steps either side of 0 shared an order.

0.30.0

Changed

  • minEngine 0.30.0: built against engine 0.30.0. A build of this package from before does not load and is rebuilt.

Added

  • Tiles carry their tileset image's filter (QuadBlit::Source::filter), so a GPU draws them as its Filter says, each tile within its own texels.
  • Tiles carry their atlas's revision (QuadBlit::Source::revision), and each opaque tile copy one of its own, so a GPU drawing the 2D (deki-gl) uploads each tile once. The map pass says it writes nothing into the frame buffer itself (RenderPass::WritesBuffer).

それ以前のリリース: CHANGELOG.md


パッケージのリフレクションデータから生成しています (エンジン 0.40.1)。プロパティ名はシーンファイルで使われるキーです。名前を変えても別名が残ります (互換性)。