How to use display.newLine to draw a Triangle and fill it and set collision boundaries ?

hi,

I’m trying to draw a triangle and set the collision boundaries to it and fill the Shape with colour. I’ve seen the example for drawing the Star, but it didn’t show how to set collision boundaries. I also read the example on adding collision boundaries complex Shapes, which are in the form of Images (Triangle.png).

What i’m trying to do is combine the two. and also fill the shape with colour.

So i used the display.newLine to set the centre of the Shape and then draw the collision boundaries. If i use display.newLine to draw a full Triangle, it gives a rectangular boundary .

This is what i could come up with.

Would appreciate some code to fix it

thanks

  
local triangle = display.newLine( 160, 240, 160, 240 )  
triangleShape = { 0,-35, 37,30, -37,30 }  
physics.addBody( triangle, "static", { density=0.9, friction=0.5, bounce=0.3, shape=triangleShape } )  
triangle:setFillColor( 210, 38, 42 )  
  

[import]uid: 10542 topic_id: 3685 reply_id: 303685[/import]

Hi,
I guess one thing that is also required, not only from Corona, but in general, “FloodFill”

How do you implement floodfill on mobile devices with colour boundaries or shape boundaries?

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3685 reply_id: 11297[/import]

Swiftelf,

Did you find a solution? I’m facing the exact same problem.

Jeroen [import]uid: 31749 topic_id: 3685 reply_id: 27290[/import]