I’m playing around with a angry bird-like physics, basically hitting a stack of blocks with a ball. Sometimes, however, the ball seems to sail straight through the blocks and I’ve isolated an example when this happens:
local physics = require("physics") physics.start() physics.setDrawMode("debug") local w = display.contentWidth local h = display.contentHeight local ball = display.newImage("ball.png") ball.x = ball.width ball.y = h-120 physics.addBody(ball, { density=2.0, friction=0.3, bounce=0.5, radius=28}) local earthPhys = display.newRect(w/2, h-60, w, 60) physics.addBody(earthPhys, "kinematic", { density=5.0, friction=0.3, bounce=0.2}) local block1 = display.newRect(0,0,50,50) local block2 = display.newRect(0,0,50,50) block1.x = 450 block1.y = h - 120 block2.x = 450 block2.y = h - 120-50 physics.addBody(block1, "dynamic", { density=2.0, friction=0.9, bounce=0.0}) physics.addBody(block2, "dynamic", { density=2.0, friction=0.9, bounce=0.0}) ball:applyLinearImpulse(250, -22)
I think I read somewhere about a setting in the physics engine to prevent these kind of things, but that it was on as default?