Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tilemap.get_tiles() function #9138

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open

Add tilemap.get_tiles() function #9138

wants to merge 6 commits into from

Conversation

AGulev
Copy link
Contributor

@AGulev AGulev commented Jun 27, 2024

Added a new function tilemap.get_tiles() which returns a table of rows with all the tile indexes for the layer.

local left, bottom, columns_count, rows_count = tilemap.get_bounds("#tilemap")
local tiles = tilemap.get_tiles("#tilemap", "layer")
local tile, count = 0, 0
for row_index = bottom, bottom + rows_count - 1 do
	for column_index = left, left + columns_count - 1 do
		tile = tiles[row_index][column_index]
		count = count + 1
	end
end

@AGulev AGulev added feature request A suggestion for a new feature engine Issues related to the Defold engine tilemap Issues related to tilemaps labels Jun 27, 2024
@AGulev AGulev requested a review from britzl June 27, 2024 13:28
Copy link
Contributor

@britzl britzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! But we need to document the order in the returned tiles table.

@AGulev AGulev requested a review from britzl June 28, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Issues related to the Defold engine feature request A suggestion for a new feature tilemap Issues related to tilemaps
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

2 participants