电晕碰撞检测

时间:2012-06-06 06:28:14

标签: lua collision-detection corona

我试图将我的物理身体之一移动到碰撞时的另一个xAxis

local function onCollision(self,event)
            if event.other.name == "block" then
                if  (event.other.x - self.x) > 210 then
                    self:removeSelf()
                    self = nil
                    transition.cancel( event.other.move )
                    event.other:removeSelf()
                    event.other = nil
                    gameOver()
                else
                    print("else")
                    transition.cancel( event.other.move )
                    event.other.x = 1024
                    updateScore(1)
                end
            end
        end
        ball.collision = onCollision
        ball("collision",ball)

但它是在说

"Cannot translate an object before collision is resolved"

我该怎么做?

2 个答案:

答案 0 :(得分:1)

如果要移动碰撞对象,则必须提供帧延迟。

替换

 event.other.x = 1024 

local translateObject = function()  event.other.x = 1024 end
timer.performWithDelay(1,translateObject,1)

答案 1 :(得分:0)

transition.to(ball,{x = object.x,y = object.x,time = 0})

我找到了问题的答案。