Objects touching
Posted: Thu Apr 17, 2014 2:05 pm
I need help trying to play a sound when objects hit something.
Code: Select all
if objects.box == objects.box2 then
love.audio.play(sound)
end
objects.box = {}
objects.box.body = love.physics.newBody(world, 160, 300, "dynamic")
objects.box.shape = love.physics.newRectangleShape(50, 100)
objects.box.fixture = love.physics.newFixture(objects.box.body, objects.box.shape)
objects.box.fixture:setRestitution(1)
objects.box.body:setFixedRotation(true)
objects.box2 = {}
objects.box2.body = love.physics.newBody(world, 880, 300, "dynamic")
objects.box2.shape = love.physics.newRectangleShape(50, 100)
objects.box2.fixture = love.physics.newFixture(objects.box2.body, objects.box2.shape)
objects.box2.fixture:setRestitution(1)
objects.box2.body:setFixedRotation(true)