Box2D collision issue
Posted: Tue Apr 21, 2015 8:39 pm
Hi,
I have tried to use Box2D to bounce a ball on a platform.
The problem is that the ball seems to hit an invisible platform and bounce some 20 pixels above the actual platform.
Any suggestion is welcome!
I have tried to use Box2D to bounce a ball on a platform.
The problem is that the ball seems to hit an invisible platform and bounce some 20 pixels above the actual platform.
Any suggestion is welcome!
love.physics.setMeter(64)
local world = love.physics.newWorld(0, 9.8 * 64, true)
objects = {}
objects.ground = {}
objects.ground.body = love.physics.newBody(world, 0, 400, "static")
objects.ground.shape = love.physics.newRectangleShape(800, 50)
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape, 1)
objects.ball = {}
objects.ball.body = love.physics.newBody(world, 220, 100, "dynamic")
objects.ball.shape = love.physics.newCircleShape(20)
objects.ball.fixture = love.physics.newFixture(objects.ball.body, objects.ball.shape, 1)
objects.ball.fixture:setRestitution(0.9)
function love.load(arg)
end
function love.draw(dt)
love.graphics.setColor(192,23, 30)
love.graphics.rectangle ("fill", objects.ground.body:getX(), objects.ground.body:getY(), 800, 50)
love.graphics.setColor(92,123, 30)
love.graphics.circle ("fill", objects.ball.body:getX(), objects.ball.body:getY(), objects.ball.shape:getRadius())
end
function love.update(dt)
world:update(dt)
end