objects givin physical properties then dont perform like so.

local leftLine = display.newLine(2, 1, 2, display.contentHeight) leftLine:setColor(100, 235, 0) local topLine = display.newLine( 1, 1, display.contentWidth - 2, 1) topLine:setColor(100, 235, 0) local rightLine = display.newLine( display.contentWidth - 2, 1, display.contentWidth - 2, display.contentHeight) rightLine:setColor(100, 235, 0) local bottomLine = display.newLine( 1, display.contentHeight, display.contentWidth - 2, display.contentHeight) bottomLine:setColor(100, 235, 0) leftLine.width = 3 rightLine.width = 3 bottomLine.width = 3 topLine.width = 3 local physics = require"physics" physics.start() physics.setGravity(0, 9.8) physics.addBody( leftLine, "static", {} ) physics.addBody( rightLine, "static", {} ) physics.addBody( topLine, "static", {} ) physics.addBody( bottomLine, "static", {} ) local ball = display.newCircle( 100, 100, 12) ball:setFillColor(100, 235, 0) physics.addBody( ball, "dynamic", { bounce = .4 } ) ball:applyForce(math.random(-10, 10), math.random(-10, 10))

Here is some code i whipped u in 5 minutes to display my problem.

i have a enclosed box, with eash side haveing a physics added to it, but when i run the code

the ball will fall through a few sections of line. So far its been the bottom left corner and the bottom of the

left line that doesn’t seem to stop the ball at all and just lets it fly by.

Im no expert at Lua nor Corona SDK but if someone could explain to me why this happens it would be very

apperciated. Thank you.

Hi David,

Instead of making your boundaries lines, make them thin rectangles.  The physics engine requires polygons, like rectangles – I don’t think you can make a line a physics object successfully.

  • Andrew

This is true. Lines don’t accept physics bodies as you might expect them to, but a rectangle of width or height of 3 would. However, be aware that if you have any fast-moving objects that are supposed to collide with these “lines”, it’s possible that they’ll pass right through because the body is so thin.

Regards,

Brent

Thankyou Brent and aukStudios, this solved my problem!

Hi David,

Instead of making your boundaries lines, make them thin rectangles.  The physics engine requires polygons, like rectangles – I don’t think you can make a line a physics object successfully.

  • Andrew

This is true. Lines don’t accept physics bodies as you might expect them to, but a rectangle of width or height of 3 would. However, be aware that if you have any fast-moving objects that are supposed to collide with these “lines”, it’s possible that they’ll pass right through because the body is so thin.

Regards,

Brent

Thankyou Brent and aukStudios, this solved my problem!