Hey all, I have been working on this for two days and I am trying to finish it up by Friday. Any help would be great!
so I have two objects, I want to spawn 10 of each like this.
ball_table = {}
hole table= {}
ball = display.newCircle(100,100,50)
hole = display.newCircle(100,100,200)
hole.myname = “hole”
for i = 1, 10 do
ball_table[i] = ball
end
for i = 1, 10 do
hole_table[i] = hole
end
I am basically trying to make it so that when a ball_table[i] collides with a hole_table[i] the ball that collided with corresponding hole, stops it’s velocity. But I can’t seem to get the collisions down for both items from both tables. If that makes sense. I have something like this.
for i = 1, #ball_table do
function ball_collision (self,event)
if event.phase == “began” then
if event.other.myname then
print(hole_table[i])
end
end
end
end
ball_table[i].collision = head_grave_collision
ball_table[i]]:addEventListener(“collision”,ball_table[i])
end
so, it print’s the ball and the number of the hole it collides with, well the table index, I still can’t get it to print a number. But I can’t get it make the ball_table[i] stop at the correct hole. If anyone could help know what I am missing or point me in the direction of a tutorial that might help, that would be really really great! thanks in advance.
Sincerely,
SM [import]uid: 79586 topic_id: 31838 reply_id: 331838[/import]