【问题标题】:In Corona SDK, why is this function returning an error?在 Corona SDK 中,为什么这个函数会返回错误?
【发布时间】:2014-12-16 03:25:57
【问题描述】:
LINE 212   function onCollision(e)
  LINE 213     transition.to(gameView, {time = 300, x = -gameView.height,  display.remove() gameView= nil   



end})

   endGame = display.newImage('end_game_background.png', display.contentWidth, display.contentHeight-   300)


    transition.to(endGame)


background.isVisible = false
lineGroup.isVisible = false




end

当我尝试运行此代码时,我收到一条错误消息: main.lua line:213: '}' 预计在 gameView 附近

【问题讨论】:

  • 什么乱七八糟的,试着改进你的代码格式。为什么会有end},它与什么配对?
  • 请格式化您的代码。我们拥有的社区是一群愿意提供帮助的志愿者。至少尊重他们的承诺,以理想的方式提出您的问题。
  • 你的意思是display.remove() 在那里吗?可能是复制粘贴错误?
  • 正确的格式也能帮助你理解你在做什么......

标签: function lua coronasdk


【解决方案1】:
transition.to(gameView, {time = 300, x = -gameView.height,  display.remove() gameView= nil 

end})

不正确,试试onCompleteonCancel,也可以用display.remove(gameView)代替display.remove()

transition.to(gameView, {time = 300, x = -gameView.height, onComplete=function() 
    display.remove(gameView)
    gameView= nil 
end})

【讨论】:

    猜你喜欢
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 2017-02-11
    • 2018-09-03
    • 2016-01-08
    • 1970-01-01
    相关资源
    最近更新 更多