如何在重新启动时删除对象并再次出现?Corona SDK。

我希望物体在碰撞时消失,然后当重新开始按钮被点击时再次出现。这是我的代码:

function touchRestart(event)
  if event.phase=="began" then
    print('foo')
  end
end
restart:addEventListener("touch",touchRestart)

function onLocalCollision(raketa,event)
  if event.phase=="began" then
    if event.object1.myName=="meteor" and event.object2.myName=="raketa" then
      score=score -1
      scoreNumber.text = score
      restart.isVisible=true
    end
  end
end
raketa.collision = onLocalCollision
Runtime:addEventListener("collision",raketa)
点赞
用户825481
用户825481

应该很容易。

将你的 object.alpha 设定为 0,然后当你点击重置按钮时,将 object.alpha 设置为 1。

希望这能够帮到你。

2013-12-05 05:54:02