Skip to content

Added an example to iso_diamond example for handling tile clicks in respect to the 2d camera#529

Open
ThunderSizzle wants to merge 2 commits into
StarArawn:mainfrom
ThunderSizzle:click-to-tile-example-to-iso-diamond
Open

Added an example to iso_diamond example for handling tile clicks in respect to the 2d camera#529
ThunderSizzle wants to merge 2 commits into
StarArawn:mainfrom
ThunderSizzle:click-to-tile-example-to-iso-diamond

Conversation

@ThunderSizzle
Copy link
Copy Markdown

I added an example to iso_diamond's example for working with the cursor position with the tile map. This permits the user to click on any tile to change the color while the example is running. Left clicking increments the tile's color index, and right clicking decrements the tile's color index.

This is to offer an example for this issue: https://github.com/StarArawn/bevy_ecs_tilemap/issues/305Issue 305

--
Part of the reason for this example is that it took me the better part of a week to figure out how to do this. I wanted an example of this to be accessible.

@rparrett
Copy link
Copy Markdown
Collaborator

This seems to be implementing Bevy's viewport_to_world_2d manually. I think #305 probably predates that addition to Bevy, and can be closed now.

We also have a mouse_to_tile example that works with iso diamond.

@ThunderSizzle
Copy link
Copy Markdown
Author

@rparrett: Thanks for reviewing. I see now my misunderstanding of the mouse_to_tile example. I didn't realize that "CursorPos" was self-contained in the example. I attempted using TilePos::from_world_pos using the cursor position from the window, which obviously didn't work, hence how I guess ended up rebuilding "viewport_to_world_2d" that I didn't know existed.

That simplifies my usage quite a bit. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants