It looks like you're new here. If you want to get involved, click one of these buttons!
Dislikes: RMTom, Salih, jdbc, aditya
if layer.objects[i].polygon == nil then else --your polygon code here end
local myShape = Shape.new() myShape:setFillStyle(Shape.SOLID, 0xff0000, 0.5) myShape:beginPath() myShape:moveTo(0,0) for j=1,#layer.objects[i].polygon do myShape:lineTo(layer.objects[i].polygon[j].x,layer.objects[i].polygon[j].y) end myShape:closePath() myShape:endPath() myShape:setPosition(layer.objects[i].x,layer.objects[i].y) myShape:setColorTransform(1,1,1,1) stage:addChild(myShape)
Likes: Tom2012
Likes: moris
Likes: hgvyas123
Comments
hi take a look at the example from @evs
http://www.giderosmobile.com/forum/discussion/699/using-tiled#Item_21
basically you need to create boxbody from the object layer so your ball will not fall down
hope it helps
so you can easily chk whether it is normal object or polygon by
http://giderosmobile.com/forum/discussion/642/example-w-box2d-and-mark-bayazit039s-polygon-decomposition-algorithm
Likes: Tom2012
That's exactly what I need for my next app.
Can't thank you enough my friend!
Likes: moris
A bit rough but shows the code that might prove helpful
- Polygons must be between 3 and 8 points to work
- You have to draw the shape in Tiled clockwise or you'll get errors.
- Shapes must be convex
- To get unusual shapes, draw more polygons.
PS if anyone would like to look at the code and fix it up I'm sure others would find it most helpful. My solution is a bit 'hacky'.
:-)
Likes: hgvyas123
- Box2D
- Scene manager
- Tiles with multiple layers in Tiled
- Polygons and box shapes
- Multiple tilesets on different layers
- Parallax scrolling
This is pretty standard stuff for platformer games like mario so in case anyone in the future needs the code, here's a working example. :-)