Migration to bevy_ecs_tiled v0.8
This guide outlines the steps required to migrate your project to version 0.8 of bevy_ecs_tiled.
Main Changes
- Improved
TiledEventAPI: Provides an unified way to handle events and access underlying Tiled data. - Attach shape information to
TiledObject: Direct access to Tiled objects shape information through ECS. - Reworked physics colliders spawning: Integrate with the
geocrate to define and aggregate colliders together. - Reworked name filter API: The filter API have been extended to use
regexand is now also used for selecting which types are exported as Tiled custom properties. - Simplify
TiledMapStorageusage: Add helpers functions to theTiledMapStoragecomponent so it's easier to work with. - Explicit
SystemSet: Allow precise systems ordering for user applications. - Rationalize naming: Several types or functions have been renamed to better reflect what they actually do.
- Source code re-organization: Several files have been moved around or renamed.
Migration Steps
-
Update the dependency in
Cargo.toml:bevy_ecs_tiled = "0.8" -
Adjust your types:
Some types have been renamed, without any functional change, or not much.
It should be safe to simply run a "search and replace" command, in the following order (make sure to match whole words):
Old name New name Functional changes ? TiledMapTiledMapAssetTiledWorldTiledWorldAssetTiledMapHandleTiledMapTiledWorldHandleTiledWorldTiledMapPluginTiledPluginTiledColliderSpawnInfosThis one was actually removed TiledMapMarkerTiledMapThis one was actually removed TiledWorldMarkerTiledWorldThis one was actually removed TiledMapLayerTiledLayerTiledLayernow holds the layer kindTiledMapTileLayerTiledLayerTiledLayernow holds the layer kindTiledMapObjectLayerTiledLayerTiledLayernow holds the layer kindTiledMapGroupLayerTiledLayerTiledLayernow holds the layer kindTiledMapImageLayerTiledLayerTiledLayernow holds the layer kindTiledMapTileLayerForTilesetTiledTilemapTiledMapTileTiledTileTiledMapObjectTiledObjectTiledMapImageTiledImage -
Adjust your functions:
Some functions have been renamed, without changing their behaviour, or not much.
It should be safe to simply run a "search and replace" command:
Old name New name get_map_typetilemap_type_from_mapget_grid_sizegrid_size_from_mapget_tile_sizetile_size_from_maptile_size_from_gridtile_size_from_grid_sizeThe following functions are now methods of the
TiledMapAssetstruct:for_each_tileworld_space_from_tiled_position(renamed fromfrom_tiled_position_to_world_space)
-
Adjust your imports:
Some modules or types have changed names or locations. If you import types using their defining path you may need to adjust.
An easy way to get past this is to import the whole prelude:
bevy_ecs_tiled::prelude::*or to use the type prelude path, such asbevy_ecs_tiled::prelude::TiledPlugin. -
Adjust
EventAPI usageThe event API has been reworked and now revolves around a generic
TiledEvent<E>structure. This provides more context for each event, including the origin of each particular eventEand helper methods to access Tiled data.See the dedicated guide on events for details.
-
Update custom physics backend
Most of the work that was done in the physics backend is now done by the crate itself which should simplify any custom physics backend implementation. As a result, the
spawn_collidersfunction from theTiledPhysicsBackendtrait have changed: you should refer to its documentation for more information. -
Update filter API usage
The filter API used to revolve around two enums:
TiledNamefor creating filters andTiledNameFilterfor matching them. It felt a bit cumbersome.
Now, everything is done via the newTiledFilterenum for doing both operations and we added support for regular expresions using theregexcrate.We also added a new parameter to
TiledPluginConfigto control which properties are exported from Bevy at startup. -
Adjust
TiledMapStoragecomponent usageFields in
TiledMapStorageare now private. You should use the provided methods instead of accessing fields directly.