bevy_tilemap icon indicating copy to clipboard operation
bevy_tilemap copied to clipboard

Ability to calculate the tile on-screen position

Open chayleaf opened this issue 3 years ago • 4 comments

What problem does this solve or what need does it fill?

Right now, the crate forces you to let it render all of the objects on the tilemap itself. However, this isn't flexible - for example, currently animations aren't supported. There needs to be an ability to render parts of it yourself (sorry if such a solution is in the crate already, I couldn't find it). There's also a much more fundamental issue - not knowing the tile coordinates makes you unable to react to mouse clicks properly

Describe the solution would you like?

An API for getting tile positions, similar to the vertex shaders but in rust.

Describe the alternative(s) you've considered?

Adding all of the features users would possibly want to the Tile struct, possibly bloating it.

chayleaf avatar Dec 27 '20 09:12 chayleaf

Need to double check, but I think I added API in one of my local branches that gets the tile coordinate from a global coordinate.

joshuajbouw avatar Dec 27 '20 10:12 joshuajbouw

Actually the tile module's description details the perfect solution - "Tile traits to implement for a custom tile". However, currently the module only has a struct, no traits.

chayleaf avatar Dec 27 '20 13:12 chayleaf

Once upon at time, it had it in the 0.1 release. Took it out for now as it was a bit.. tedious to work with. Will eventually bring it back.

joshuajbouw avatar Dec 27 '20 14:12 joshuajbouw

Ok so, I got the code for this in #94, sort of. It is not exactly straight forward. You need to feed it both the transform of what you want and then the transform of the tilemap.

joshuajbouw avatar Jan 13 '21 17:01 joshuajbouw