Hi,
I’m just trying to make a sprite re-appear on a random tile after collision with another sprite. I can’t seem to get this working! It seems simple enough but I’m not able to make this happen… is it possible that because I am in a collision that mte.update isn’t being called?
This is what I am doing:
local function onCollision( event )
if ( event.phase == “began” ) then
if event.object2.id == “hole” then
spinplayer()
function spinplayer()
timer.performWithDelay(5, function() player.rotation = player.rotation + 10 end, 100)
timer.performWithDelay(1000, relocateplayer(), 1)
end
function relocateplayer()
tx = math.floor(math.random() * 127.99)
ty= math.floor(math.random() * 127.99)
print(“Relocating x”…tx…" Y:"…ty)
– player.isVisible = false
mte.moveSpriteTo({sprite = player, locX =tx,locY= tx,time=1, onComplete = mte.setCameraFocus(player) })
– player.isVisible = true
end