Lua 在解决冲突之前无法平移对象

Lua 在解决冲突之前无法平移对象,lua,coronasdk,Lua,Coronasdk,当我编译时,这是显示 错误:在解决碰撞之前无法平移对象 当我为android构建应用程序时,它会显示一个error5 null 这是我的密码: function onLocalCollision(meteor, event) if event.phase == "began" then if event.object1.myName == "meteor" and event.object2.myName == "rocket" then score = score -

当我编译时,这是显示

错误:在解决碰撞之前无法平移对象

当我为android构建应用程序时,它会显示一个error5 null

这是我的密码:

function onLocalCollision(meteor, event)
  if event.phase == "began" then
  if event.object1.myName == "meteor" and
     event.object2.myName == "rocket" then
    score = score - 1
    scoreNumber.text = score
    restart.isVisible = true
    meteor.x = 500   
    meteor.y = 300
    meteor2.x = 500
    meteor2.y = 200
    meteor3.x = 500
    meteor3.y = 100
    event.object2.alpha = 0.2
    rocket:applyForce(-150,0,rocket.x,rocket.y)
    lives = lives -1
    livesNumber.text = lives
    if lives < 1 then
    lives = 3
    score = 0
    scoreNumber.isVisible = false
    livesText.isVisible = false
    livesNumber.isVisible=false
    hearticon.isVisible = false
    scoreText.isVisible = false
    gameover.isVisible = true
    restart.x = 100000
    end
  end
  end
end


meteor.collision = onLocalCollision
Runtime:addEventListener("collision", meteor)

代码的问题是在冲突函数期间无法进行翻译,因此如果您只说:timer.performWithDelay100,function rocket:applyForce-150,0,rocket.x,rocket.y end,1,则应该可以解决问题和/或创建回调函数

修改对象 在碰撞事件期间,不应移除碰撞中涉及的对象或更改其任何属性。如果要修改碰撞事件中的对象位置值或其他属性,则应使用timer.performWithDelay

删除对象或修改碰撞事件中的属性可能会导致模拟器崩溃