Greetings! Can someone please help me figure out why my contact function doesn’t seem to be working right?
In set up
ball_d = 60
p_ball = physics.body(CIRCLE,ball_d / 2)
p_ball.x = (math.random(200,600))
p_ball.y = (math.random(200,600))
p_ball.gravityScale = 1
p_ball.restitution = .8
p_ball.friction = 1
p_ball.info = 'p_ball'
p_ball.linearVelocity = vec2(math.random(400),math.random(400))
p_ball.linearVelocity=vec2(math.random(400),math.random(400))
function collide (contact)
if contact.state == BEGAN then
if contact.bodyA.info == 'p_ball' or contact.bodyB.info == 'p_ball' then
sound(SOUND_HIT, 27276)
print("Contact")
end
end
end
I’m not sure if this is all the code I need to bring so please tell if its not.
I also read this guide to help me make this but it dint seem to give the solution to my problem.
http://coolcodea.wordpress.com/2013/03/21/6-more-physics