Question

I am using Gideros, Here is the code that I have to check for collisions, but what is really happening is collision is printed only 3 times since there are only 3 members in groupA, I want to check collisions with all 3 but obviously as long as game is running, so how can I check for every collision that my second sprite(cute) happens to have with any of the 3 objects grouped in groupA ?

for i = 1, groupA:getNumChildren() do
local sprite = groupA:getChildAt(i) 
local x,y,w,h = groupA:getBounds(stage)
local x2,y2,w2,h2 = cute:getBounds(stage)
if not ((y+h < y2) or (y > y2+h2) or (x > x2+w2) or (x+w < x2)) then
print("collision")
end
end
Was it helpful?

Solution

You would need to put this loop in ENTER_FRAME event to check for collisions on each frame

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top