0
votes

i am trying to move one of my physics body to a different xAxis on collision

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)

but it is saying

"Cannot translate an object before collision is resolved"

How can I do that ?

2

2 Answers

1
votes

You have to give a frame delay if you want to move colliding objects.

Replace

 event.other.x = 1024 

with

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

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

I found the answer to the question.