StarArawn / bevy_tiled

A plugin for rendering tiled maps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changin rendered maps

josebaMdeL opened this issue · comments

Hi!

I'm using this plugin to make a game and I'm trying to be able to change from main menu to a map, and from the map to another map.

My idea was to load a default instance of TiledMapComponents at startup, and then use a system where I query the componetn with:
mut tiled_map: Query<&mut TiledMapComponents>,

and make something like:

            for mut c in tiled_map.iter_mut() {
                println!("Showing map...");
                c.map_asset = asset_server.load(map_path.as_str()); // here we load the new map
                c.center = TiledMapCenter::default(); // This centers the map view again, I guess?
            }

The problem is that I don't know why the query comes empty, when it should have the only TiledMapComponents component that was spawned at startup, so I can't make any changes on rendered map.

Also, if I try to commands.despawn, or despawn_recursive, the game crashes at:
(line 454 of maps.rs file.

let map = maps.get_mut(changed_map).unwrap();

Any idea what could be happening?

TilemapComponents is not persisted currently, so you can't query for it In the next week or two I plan to push changes targeting bevy/main which allow you to pass a toplevel entity in, but that is not here yet. It is on my fork for now, if you want to try it out:

Hi!,

Thanks for the respond, but I finally get my own rendering system.