just_tiled 0.3.0
just_tiled: ^0.3.0 copied to clipboard
Tiled Map Editor (TMX/TSX) parser and renderer for 2D game engines.
Changelog #
0.3.0 - 2026-04-22 #
Breaking #
Layer.parallelX/parallelYrenamed toparallaxX/parallaxY.
Fixed #
TileMapRenderer: corrected H/V/diagonal tile flip logic in bothcompile()and_renderCulled();_tileCountnow reflects actual compiled tiles.TileMapParser: template-load errors now logged in debug mode instead of silently swallowed;_parsePointsStringusestryParseto avoid crashes on malformed data;_mergeTemplateObjectrespects the Tiled 1.9+classattribute on templates.SpatialHashGrid: fixed_hashbit-shift that caused collisions for symmetric coordinates;queryRadiusis now O(1) per candidate via a cached bounds map.
Added #
TileMapRenderer.dispose()for releasing the atlasui.Image.
Tests #
- Expanded from 5 to 46 tests.
0.2.0 - 2026-03-15 #
Added #
- Example (
example/example.dart) — full Flutter app demonstrating map parsing, texture atlas construction,TileMapRendererusage, object querying, custom property access, and
0.1.0 - 2026-03-15 #
Added #
-
TileMapParser — async TMX/TSX parser built on the
xmlpackage.TileMapParser.parse(String tmxXml, {TsxProvider?})returns a fully-populatedTiledMap.- Encodings: CSV, Base64, XML (unencoded).
- Compression: None, GZIP, Zlib (via
archive), Zstd (viajust_zstd). - Decodes flip bits (horizontal, vertical, diagonal / anti-diagonal) from GIDs and stores them separately.
- Parses embedded and external tileset references; resolves
.tsxfiles via the injectedTsxProvider. - Parses tile animation frame sequences (
<animation>elements). - Parses per-tile collision shapes (polygon / circle objects).
- Typed custom property system:
string,int,float,bool,color,file. - Object template inheritance with per-instance property overrides.
- Tile draw offsets for isometric / staggered alignment.
-
TsxProvider — dependency injection interface for resolving external assets.
DefaultTsxProviderimplementation loads.tsxand template files from the Flutter asset bundle with automatic path normalisation.
-
Data models — immutable value types covering the full Tiled document graph.
TiledMap— root document with computedpixelWidth/pixelHeight,tileLayers,objectGroups,imageLayers, andfindTilesetForGid().- Layer hierarchy — abstract
Layerbase with four concrete types:TileLayer,ObjectGroup,ImageLayer,GroupLayer(nestable). - Common layer properties:
id,name,visible,opacity,offsetX/Y,tintColor,parallelX/Y(parallax factors). Tileset—firstGid, dimensions, spacing, margin,tileOffset, image metadata, per-tile map, andgetSourceRect(localId).Tile—id,type,probability, optional image, collisionobjectGroup,animationframes, custom properties.AnimationFrame—tileId+duration(ms).TiledObject— rectangle, polygon, polyline, ellipse, point, tile object, text object;rotation,gid, template path.TiledProperties— typed accessors:getString(),getInt(),getDouble(),getBool(),has(),operator[].- Enums:
MapOrientation(orthogonal, isometric, staggered, hexagonal),RenderOrder,StaggerAxis,StaggerIndex,DrawOrder,LayerEncoding,LayerCompression.
-
TextureAtlas / TextureAtlasCollection — GPU-optimised tile texture mapping.
TextureAtlaspre-computes sourceRects for every tile in a tileset on construction.TextureAtlasCollection.lookup(gid)resolves the correct atlas and source rect for any GID across multiple tilesets (sorted byfirstGid).
-
TileMapRenderer — hardware-accelerated Canvas renderer.
compile()converts a tile layer toFloat32ListRSTransform + source-rect buffers for a singleCanvas.drawRawAtlascall per layer.render(canvas, cameraOffset, visibleBounds)renders a compiled layer.- Map orientations: Orthogonal, Isometric, Staggered (X/Y axis), Hexagonal — full coordinate transformation for each.
- Tile flipping: Horizontal, Vertical, Diagonal encoded into RSTransform (
scos,ssin,tx,ty). - Layer properties: opacity, tint colour, layer offset, parallax factors.
- Frustum culling: automatic tile-level culling for maps with > 10 000 tiles.
invalidate()marks a renderer for recompilation on the next frame.
-
SpatialHashGrid<T> — generic 2-D spatial index.
insert(),remove(),update()for dynamic objects.query(Rect)AABB query,queryPoint(Offset),queryRadius(Offset, double)circular proximity query.- O(1) average cell hashing via prime multiplication.