Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 TiledEvent API: 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 geo crate to define and aggregate colliders together.
  • Reworked name filter API: The filter API have been extended to use regex and is now also used for selecting which types are exported as Tiled custom properties.
  • Simplify TiledMapStorage usage: Add helpers functions to the TiledMapStorage component 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

  1. Update the dependency in Cargo.toml:

    bevy_ecs_tiled = "0.8"
    
  2. 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 nameNew nameFunctional changes ?
    TiledMapTiledMapAsset
    TiledWorldTiledWorldAsset
    TiledMapHandleTiledMap
    TiledWorldHandleTiledWorld
    TiledMapPluginTiledPlugin
    TiledColliderSpawnInfosThis one was actually removed
    TiledMapMarkerTiledMapThis one was actually removed
    TiledWorldMarkerTiledWorldThis one was actually removed
    TiledMapLayerTiledLayerTiledLayer now holds the layer kind
    TiledMapTileLayerTiledLayerTiledLayer now holds the layer kind
    TiledMapObjectLayerTiledLayerTiledLayer now holds the layer kind
    TiledMapGroupLayerTiledLayerTiledLayer now holds the layer kind
    TiledMapImageLayerTiledLayerTiledLayer now holds the layer kind
    TiledMapTileLayerForTilesetTiledTilemap
    TiledMapTileTiledTile
    TiledMapObjectTiledObject
    TiledMapImageTiledImage
  3. 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 nameNew name
    get_map_typetilemap_type_from_map
    get_grid_sizegrid_size_from_map
    get_tile_sizetile_size_from_map
    tile_size_from_gridtile_size_from_grid_size

    The following functions are now methods of the TiledMapAsset struct:

    • for_each_tile
    • world_space_from_tiled_position (renamed from from_tiled_position_to_world_space)
  4. 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 as bevy_ecs_tiled::prelude::TiledPlugin.

  5. Adjust Event API usage

    The 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 event E and helper methods to access Tiled data.

    See the dedicated guide on events for details.

  6. 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_colliders function from the TiledPhysicsBackend trait have changed: you should refer to its documentation for more information.

  7. Update filter API usage

    The filter API used to revolve around two enums: TiledName for creating filters and TiledNameFilter for matching them. It felt a bit cumbersome.
    Now, everything is done via the new TiledFilter enum for doing both operations and we added support for regular expresions using the regex crate.

    We also added a new parameter to TiledPluginConfig to control which properties are exported from Bevy at startup.

  8. Adjust TiledMapStorage component usage

    Fields in TiledMapStorage are now private. You should use the provided methods instead of accessing fields directly.

Resources