0

我试图在碰撞时将我的一个物理体移动到不同的 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"

我怎样才能做到这一点 ?

4

2 回答 2

1

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

代替

 event.other.x = 1024 

local translateObject = function()  event.other.x = 1024 end
timer.performWithDelay(1,translateObject,1)
于 2012-06-06T17:29:09.683 回答
0

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

我找到了问题的答案。

于 2013-12-18T12:04:07.840 回答