In trying to change the position of a display object ‘Wall’ on collision with one called ‘Ball’ by altering its x and/or y value, I kept getting “ERROR: Cannot translate an object before collision is resolved” if I executed the command in either the “ended” or “postCollision” event phases.
So, this causes an error:
local function wallCol (self,e)
if e.other.id ~= "ground" then
if e.phase == "ended" then
wall.x = wall.x + 20
end
end
end
I also tried changing bodyTypes of the objects on collision, resetting all velocities to 0, etc, but the only thing that works is making the move a function and executing it with a delay:
local function wallCol (self,e)
if e.other.id ~= "ground" then
if e.phase == "ended" then
local function moveWall()
print("Move @ "..system.getTimer())
wall.x = wall.x + 20
end
timer.performWithDelay(1, moveWall)
end
end
end
works fine. It seems that neither the “ended” nor “postCollision” state means a collision is truly resolved and the object is available for manipulation.
Using system.getTimer() shows that the “ended” and “postCollision” phases happen at the same time, so they apparently denote the same thing. Seems like a bug, unless I’m missing something. [import]uid: 41305 topic_id: 7418 reply_id: 307418[/import]