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

Missing way to get generated tiles from AutoLayer in integer coordinates #21

Open
zommerfelds opened this issue Nov 29, 2022 · 0 comments

Comments

@zommerfelds
Copy link
Contributor

Issue

The Layer_Tiles has the useful function getTileStackAt() or hasAnyTileAt(). However, if you use an IntGrid or AutoLayer, there is no such way to get the tiles by integer coordinates. The only public value currently is:

public var autoTiles : Array<ldtk.Layer_AutoLayer.AutoTile>;

Which only exposes the pixel positions:

typedef AutoTile = {
/**
X coordinate to place this tile in your render
**/
var renderX: Int;
/**
Y coordinate to place this tile in your render
**/
var renderY: Int;

It would be nice to add getTileStackAt() or hasAnyTileAt() to the Layer_IntGrid_AutoLayer class.

Potential solutions

I'd propose to add a new variable which is a map, like it the Tiles layer:

var tiles : Map<Int, Array<{ tileId:Int, flipBits:Int }>>;

Then we can use coordinate IDs to find the right tile. The only problem here is that we'd be duplicating data with the autoTiles variable (changing it would be backwards incompatible since the variable is public). As an alternative 1 we can create a private Map<Int, Array<Int>> which just contains indices to the autoTiles variable. Or alternative 2 is to make the autoTitles a Haxe property with a getter function that is backed by the new variable. I think i prefer alternative 2.

What do you think? Happy to try to make a pull request with the preferred solution.

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

No branches or pull requests

1 participant