在Corona中的碰撞检测

我正在尝试在碰撞后将一物理体移动到不同的X轴。但是它会提示“无法在碰撞解决之前翻译对象”。我该如何解决?

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)
点赞
用户1137788
用户1137788

如果想移动碰撞对象,您必须给出一个帧延迟。

用以下代码替换:

 event.other.x = 1024

替换为

local translateObject = function()  event.other.x = 1024 end
timer.performWithDelay(1,translateObject,1)
2012-06-06 17:29:09
用户2579014
用户2579014
transition.to(ball, {x = object.x, y= object.x, time=0})

我找到了这个问题的答案。

2013-12-18 12:04:07