Hi Guys,
I was wondering if any of you corona elite developers had any tips on how to accomplish the following:
• I have marbles a bunch of different colors. I want to fire an event if three or more of the same marbles collide/touch eachother, but not if only two of the same marbles collide/touch eachother. The event I want to fire is to remove the colliding marbles.
Kinda like in Bejeweled. What would be the best way to do this? I tried the collision event but I can’t think of a way to detect three marbles of the same color, instead of two marbles of the same color!
Right now I have this, but as you can see this goes off even if there’s only two of the same marbles touching eachother:
local function onLocalCollision(self, event)
if (event.phase == "began") then
if (self.myName == "red" and event.other.myName == "red") then
self:removeSelf()
event.other:removeSelf();
end
if (self.myName == "yellow" and event.other.myName == "yellow") then
self:removeSelf()
event.other:removeSelf();
end
if (self.myName == "green" and event.other.myName == "green") then
self:removeSelf()
event.other:removeSelf();
end
end
end
Thanks alot! [import]uid: 32882 topic_id: 28563 reply_id: 328563[/import]
