【问题标题】:Lua - Corona SDK How to fix this or change the code to make it work properly?Lua - Corona SDK 如何解决此问题或更改代码以使其正常工作?
【发布时间】:2017-05-29 05:24:31
【问题描述】:

错误显示“超过 60 个上值”

ball:addEventListener( "tap", function1 )
eggs:addEventListener( "tap", function2 )
dog:addEventListener( "tap", function3 )
car:addEventListener( "tap", function4 )
...
plane:addEventListener( "tap", function52 )

我已经对所有东西都进行了编程。当我删除任何 20 行事件监听器应用程序时。因此,事件侦听器可能存在限制。我不知道如何尽可能地改变它。

我需要使用矩形作为听众的按钮。不是像其他文章那样的变量。

【问题讨论】:

  • 我不确定,但我认为事件侦听器的数量没有任何限制。监听器 function1function2 有何区别?
  • @ldurniat Lua 默认将 upvalue 的数量限制为 60。这与电晕无关
  • 在询问堆栈溢出问题之前只需 google 错误消息。
  • @Piglet 但我写的内容一无所有。我需要对矩形按钮使用Listiners(不是那篇文章中的变量)

标签: android lua coronasdk


【解决方案1】:

不要这样做:

function function1()
  print "tapped ball"
end
function function2()
  print "tapped eggs"
end
...
ball:addEventListener( "tap", function1 )
eggs:addEventListener( "tap", function2 )

尝试这样做:

ball:addEventListener( "tap", function()
  print("tapped ball")
end)
eggs:addEventListener( "tap", function()
  print("tapped eggs")
end)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多