-
Notifications
You must be signed in to change notification settings - Fork 435
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
FlxTilemap#loadMap(): support Array<Array<Int>> instead of Array<Int>, closes #1290, closes #1324 #1292
Conversation
@gamedevsam You think this is an acceptable breaking change? |
Does this break compatibility with maps loaded from Tiled Editor? |
Not sure, I think they use csv for loading? |
No, they use in array that can be compressed with gzip or json. |
Perhaps we should split this up into several functions? |
Perhaps, but I don't like the idea of duplicating code... |
If done right, this shouldn't introduce any redundancies. |
Seems like a good change then, although it does complicate the API slightly. Also LoadMap should be refactored to be LoadMapFromCSV() Let's make it all very explicit. |
If only haxe supported overloading. :) I don't think this complicates the API actually, it might make it simpler to understand actually. |
Hm... Since the render refactor, there's a |
@Gama11 i don't think that there is big problem with updating pull request. I can do it myself if you want to. |
Yes, that's exactly the issue. I wanted to split |
maybe we could add some sort of helper method, which will convert 1d-array to 2d-array to avoid this? |
That would work, but it seems pretty inefficient - convert 1d array to 2d and then back again to 1d (since that's the format that FlxTilemap ends up using). |
let me some time to think about it |
i've removed |
Conflicts: flixel/system/FlxAssets.hx
Conflicts: flixel/tile/FlxBaseTilemap.hx
Updated. |
// Figure out the map dimensions based on the data string | ||
_data = new Array<Int>(); | ||
var columns:Array<String>; | ||
var rows:Array<String> = StringTools.trim(cast (MapData, String)).split("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why casting here?
i think this pull request can be merged, but we'll need to update TiledEditor, HeatmapPathfinding, Tilemap, GridMovement and FlipRotationAnimationTiles demoes, since it makes widthInTiles and heightInTiles read-only |
and other demoes where tilemaps are used |
Supporting both 2D and 1D-arrays here is suprisingly difficult due to the use of
Dynamic
and target-specfic differences, so I decided to drop support for the latter. A 2D array is much more natural representation of map data anyway. Loading maps with array is very inconvenient / awkward as is, aswidthInTiles
andheightInTiles
have to be set in advance.