Replies: 1 comment 2 replies
-
Hi @tfkfan Sorry for the delay, there isn't a built in way yet in the Tiled plugin to draw the polygons automatically. This does sound like a useful feature to add though! Currently the polygon objects are accessible in the const map = new TiledMapResource(...);
const loader = new ex.Loader([map]);
game.start(loader).then(() => {
...
const objectLayer = map.data.getObjectLayerByName('Objects');
const polygons = objectLayer.getPolygons();
for (let tiledPolygon of polygons) {
const offset = ex.vec(tiledPolygon.x, tiledPolygon.y);
const points = tiledPolygon.polygon;
const polyGraphic = new ex.Polygon({
points: points.map(p => ex.vec(p.x, p.y)),
color: ex.Color.Yellow,
});
const star = new ex.Actor({
pos: offset
})
star.graphics.anchor = ex.vec(0, .5);
star.graphics.use(polyGraphic);
game.add(star);
}
...
}); Result: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, didn't find some efficient way to implement this, I have a list of polygons parsed from tilemap and It should be drawn on scene
Beta Was this translation helpful? Give feedback.
All reactions