我正在使用Gideros, 这是我必须检查碰撞的代码,但真正发生的是碰撞只打印3次,因为groupA中只有3个成员,我想检查所有3个碰撞,但显然只要游戏正在运行,那么如何检查我的第二个精灵(可爱)碰巧与groupA中分组的3个对象中的任何一个碰撞?
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
答案 0 :(得分:2)
您需要将此循环放在ENTER_FRAME事件中以检查每个帧上的冲突