Hi,
I’m having the same issue but I don’t know what there’s wrong in my code. It would be nice if someone could have a look at it because sometimes four eyes see more than two 
I made a simple game where the goal is to “destroy” some rectangles (called fluffies). Sounds pretty simple, but the fluffies can only be destroyed if they’re in a collision with a fluffie which’s the same color.
My objects (called Fluffies) are created with the following code.
fluffies = display.newGroup()
for i=0, 8, 1 do -- Rows
for d=0, 5, 1 do
color = math.random(1,4)
if(color == 1) then
fluffie = display.newImage("red\_thing.png")
fluffie.color = "red"
elseif(color == 2) then
fluffie = display.newImage("green\_thing.png")
fluffie.color = "green"
elseif(color == 3) then
fluffie = display.newImage("blue\_thing.png")
fluffie.color = "blue"
elseif(color == 4) then
fluffie = display.newImage("yellow\_thing.png")
fluffie.color = "yellow"
elseif(color == 5) then
fluffie = display.newImage("purple\_thing.png")
fluffie.color = "purple"
end
fluffie:setReferencePoint(display.TopLeftReferencePoint)
fluffie.x = 15 + (d \* 75)
fluffie.y = 15 + (i \* 75)
fluffie.width = 75
fluffie.height = 75
fluffie.id = fluffies.numChildren + 1
fluffie:setReferencePoint(display.CenterReferencePoint)
fluffie:addEventListener('touch', onTouch)
fluffie.collisions = {}
physics.addBody( fluffie, { density = 1.5, friction = 0.1, bounce = 0})
fluffies:insert(fluffie)
end
end
Then I have the following code for the collision, as you can see above every fluffie has a table in which all it’s ‘neighbours’ are stored:
function hitTest( event)
if ( event.phase == "began" ) then
if(event.object1.color == event.object2.color) then
event.object1.collisions[event.object2.id] = event.object2
event.object2.collisions[event.object1.id] = event.object1
return true
end
end
if ( event.phase == "ended" ) then
if(event.object1.color == event.object2.color) then
event.object1.collisions[event.object2.id] = nil
event.object2.collisions[event.object1.id] = nil
return true
end
end
end
And finally here’s my code to destroy the fluffies, it uses the table to destroy all the fluffies which have the same color and are in a collision with each other:
function onTouch(event)
local phase = event.phase
if(phase == "began") then
combo = 0
for i,v in pairs(event.target.collisions) do
for d,v in pairs(event.target.collisions[i].collisions) do
event.target.collisions[i].collisions[d]:removeSelf()
combo = combo + 1
anzfluffies = anzfluffies + 1
end
event.target.collisions[i]:removeSelf()
combo = combo + 1
anzfluffies = anzfluffies + 1
end
if(combo \> 0) then
print(combo)
event.target:removeSelf()
anzfluffies = anzfluffies + 1
scoreDisplay:setText( anzfluffies.." / 54" )
else
print('not enough neighboours')
end
end
return true;
end
The problem is, that sometimes - I don’t know why - some fluffies aren’t destroyed and the following error message appears in the console:
Runtime error path/main.lua:148: attempt to call method 'removeSelf' (a nil value)
Sometimes I can kill all the fluffies without any error and sometimes every third group of fluffies can’t be destroyed because of that error.
Maybe I am doing something wrong in my code, I don’t know but I’m trying to fix this problem for hours now and it would be nice if you could help me 
Thank you very much,
Michael [import]uid: 8121 topic_id: 1917 reply_id: 8837[/import]