StarArawn / bevy_ecs_tilemap

A tilemap rendering crate for bevy which is more ECS friendly.
MIT License
943 stars 198 forks source link

layers and moving sprites #534

Open Mergpijp opened 5 months ago

Mergpijp commented 5 months ago

Hello,

I have a 3 layered map and a highlighter to see cursor and possible movements. Now I have placed my character at x=0, y=0 I also gave it a TilePos 32, 31. I want to move the character I want to use transform with a query how do i convert a TilePos to a real world 2d coordinate? I only found TilePos::from_world_post() function. Thanks in advance.

rparrett commented 5 months ago

It sounds like you're looking for TilePos::center_in_world.

Mergpijp commented 5 months ago

Hi, thank you very much I think that is it couldnt test it yet because I am still busy I have a problem with the double Transform queries I know i need to use Without but what without for this package? mut characters: Query<(&mut Transform, &mut Player, Without<TilemapBundle>,)>, //mut mousebtn_evr: EventReader<MouseButtonInput>, mouse_button: Res<ButtonInput<MouseButton>>, // We'll actually change the map contents for highlighting window_query: Query<Entity, With<PrimaryWindow>>, q_window: Query<&Window, With<PrimaryWindow>>, mut cursor_pos: ResMut<CursorPos>, //camera_q: Query<(&GlobalTransform, &Camera)>, previous_highlighted: ResMut<PreviousHighlighted>, tilemap_q: Query<( &TilemapSize, &TilemapGridSize, &TilemapType, &TileStorage, &Transform, Without<Player>, )>, //mut tid: Query<&mut TileTextureIndex>,) tid: Query<&mut TileTextureIndex>, )

Mergpijp commented 5 months ago

Okay I am sorry it was: Without TilemapId

Mergpijp commented 5 months ago

If i do that translation on my character with TilePos::center_in_world. It places the character not on tile but on a different location how can this be? do i need more conversion because axis start in the center? Also I used mouse_to_tile example should I make a draw function or just draw in the Cursor moved event? Is there overhead making more updates? It seems i can only draw in the cursor moved event why is this?