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

SUGGESTION: Add function to set/update FlxTilemap with an Array #3098

Open
SeiferTim opened this issue Apr 4, 2024 · 3 comments
Open

SUGGESTION: Add function to set/update FlxTilemap with an Array #3098

SeiferTim opened this issue Apr 4, 2024 · 3 comments

Comments

@SeiferTim
Copy link
Member

Currently, if you want to change the value(s) of a FlxTilemap you can either call setTile or one of the load functions.

If you want to replace the entire tilemap's data, you have to loop through each tile, or call a load function and pass all the parameters, including the tile graphic again.

If the tile graphic no longer exists, this is not viable.

I propose a function: setData which would take an Array<Int> and just replaces _data with this new array and does all the updating stuff that setTile needs to do.

@Geokureli
Copy link
Member

we talked about this in discord, sounds like you want a loadMapFromArray but without graphic data, I suggest we make an equivalent for loadMapFromCSV, loadMapFromArray, loadMapFrom2DArray and loadMapFromGraphic, I'm thinking
setTilesFromCSV, setTilesFromArray, setTilesFrom2DArray and setTilesFromGraphic

@SeiferTim
Copy link
Member Author

we talked about this in discord, sounds like you want a loadMapFromArray but without graphic data, I suggest we make an equivalent for loadMapFromCSV, loadMapFromArray, loadMapFrom2DArray and loadMapFromGraphic, I'm thinking setTilesFromCSV, setTilesFromArray, setTilesFrom2DArray and setTilesFromGraphic

Makes sense to me.

When the ONLY thing you are changing is the data, and nothing else needs to change (widthByTiles, AutoTiles, etc) makes no sense to go through the whole loadMap stuff again.

@Geokureli
Copy link
Member

whoever implements this, consider what happens if this is called before a graphic is set, is it possible for that to work without crashing or should we warn or throw an error? should we also add a way to set the graphic? should setGraphic work for this, will that set _tileWidth and stuff?

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

2 participants