DEKI/ENGINE 文档
deki-tiledmapeditor-integration 0.19.0
Deki 包参考
deki-tiledmapeditor-integration

Tiled 地图编辑器集成。将 .tmj 文件放进项目,编辑器会将其烘焙为可流式读取的二进制瓦片地图。

仓库:github.com/dekiengine/deki-tiledmapeditor-integration · 最新版本:0.19.0 · 需要引擎 0.19.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 允许时显示 水平方向一次重复的宽度,以图块为单位。0 表示使用地图自身的宽度。
loopY bool false 在垂直方向重复碰撞。
wrapPeriodY int32 0 loopY 允许时显示 垂直方向一次重复的高度,以图块为单位。0 表示使用地图自身的高度。

TilemapComponent

绘制 Tiled 地图,在相机周围流式加载区块。

检视器中的名称:瓦片地图组件 · 类别:瓦片地图 · 类型:DekiTiledMap::TilemapComponent

属性 类型 默认值 约束 说明
tilemap AssetRef (Tilemap) "" 从 Tiled 导出的地图。
visibleLayerMask int32 2147483647 要绘制地图的哪些图层,每个图层一位。所有位都置位时绘制全部图层。
chunkPadding int32 1 在屏幕边缘之外保持加载和绘制的区块数。留一点边距可以避免滚动时图块在边缘突然出现。
chunkCacheKiB int32 256 16 到 262144 此地图可用于保存已解码区块的内存量,单位为 KiB。超出预算时,最久未绘制的区块会被丢弃,再次需要时从存储中重新读取。因此设得太小的表现是滚动时卡顿,而不是内容缺失。ESP32 适合用 256;桌面平台可以用得多得多。
tintColor Color "#FFFFFFFF" 与每个图块相乘。白色则保持地图不变。
pixelsPerMeter float 16 1 到 256 地图上多少像素算作一米。地图正是靠它与场景中的其他内容对齐。
loopX bool false 在水平方向重复地图,滚动越过边缘时会绕回另一侧。
wrapPeriodX int32 0 loopX 允许时显示 水平方向一次重复的宽度,以图块为单位。0 表示使用地图自身的宽度。
loopY bool false 在垂直方向重复地图。
wrapPeriodY int32 0 loopY 允许时显示 垂直方向一次重复的高度,以图块为单位。0 表示使用地图自身的高度。

从 RendererComponent 继承 sortingOrder, ignoreClip, pixelSnap, alphaMode。

TilemapObjectSpawner

场景加载时,根据 Tiled 地图的对象图层生成对象。

检视器中的名称:瓦片地图对象生成器 · 类别:瓦片地图 · 类型:DekiTiledMap::TilemapObjectSpawner

属性 类型 默认值 约束 说明
tilemap AssetRef (Tilemap) "" 读取其对象图层的地图。在 Tiled 中放置的每个对象都会成为场景中的对象。
pixelsPerMeter float 16 1 到 256 地图上多少像素算作一米,使生成的对象落在 Tiled 中放置的位置。

更新日志

更新日志为英文。

0.19.0

Changed

  • minEngine 0.19.0: built against engine 0.19.0, whose component metadata records the package each class is in. A build of this package from before does not load and is rebuilt.

Added

  • Japanese, Simplified Chinese and Korean: editor/lang/ja.json, zh.json and ko.json translate the names, tooltips and enum values this package's components show in the Inspector.
  • The package's editor text goes through the editor's translation (Tr), so it shows in the editor's language. Needs the editor release that adds Localization.h; raise minEngine to it when releasing.

0.18.0

Changed

  • minEngine 0.18.0. Reflection ABI 21: the package must be rebuilt.
  • Names follow the code style (deki-engine/docs/codestyle): types, functions and enum values are PascalCase, constants kPascalCase, members m_PascalCase, locals and parameters camelCase. The code is formatted with clang-format 22.
  • The functions the editor finds by name are PascalCase: DekiTilemapRegisterComponents, DekiTilemapGetAutoComponentCount, DekiTilemapEnsureRegistered and the rest. Built against engine ABI 21; a build of this package from before does not load and is rebuilt.
  • Renamed: AssetTypeName is kAssetTypeName, GID_INDEX_MASK and the other gid flags are kGidIndexMask, ..., CHUNK_FLAG_EMPTY is ChunkFlagEmpty.

Fixed

  • The Chunk Padding tooltip says it counts chunks; it said tiles.
  • Builds for ESP32 boards again (0.17.0 did not): the Max Size change called std::max with an int and an int32_t, which is long on Xtensa, and left two members of the tile lookup uninitialised, an error there.
  • Object properties load. The baker wrote every object's properties, but the loader never read them back, so Properties() was always empty and a TilemapObjectSpawner never found an object's scene_guid. The map header now says where the properties, points and strings are. New: Tilemap::ObjectProperties(object, count).
  • Polygon and polyline points are written. Objects had a point count but the points themselves were never baked. DTilemapObject::pointOffset is now the object's first point in PolygonPoints(). Maps baked before this have no points until they are baked again.
  • A map no longer reads its whole object list into memory twice.
  • Corrupt map and tileset files are refused instead of crashing: every table is checked against the file's size, the per-layer object counts can no longer wrap and overflow the object table, chunk sides must be 1 to 1024 (zero divided by zero in the collider, a huge one overflowed the chunk buffer on 32-bit boards), and a tileset's animation frame counts can no longer wrap.

Removed

  • Reading maps baked before the header said where the pools are. The editor bakes every map again (asset cache version 5).
  • The former names from before 0.16.0 (bare class names, and deki-gpio's DekiEsp32::ESP32PinSetup). A scene that old is upgraded with 0.17 first.

更早的版本:CHANGELOG.md


由包的反射数据生成(引擎 0.19.0)。属性名就是场景文件中使用的键。重命名后会保留别名(兼容性)。