电晕“蜱虫”问题 - addEventListener
我一直在尝试使用 Corona SDK(使用 Lua)编写自定义刻度。关键似乎是这些“事件监听器”,但我也试图让它们与类一起工作。现在我已经设置了“世界”类。我正在尝试将 EventListener 添加到我的“tick”函数中,但 Corona 告诉我不能这样做。
function World:tick()
--player:tick()
--camera:tick(player.x,player.y)
--for i=0,monsters.length do
-- monster[i]:tick()
if(rwalk) then
mainGroup.x = mainGroup.x-10
elseif(lwalk) then
mainGroup.x = mainGroup.x+10
end
end
Runtime:addEventListener("enterFrame",tick)
错误:运行时错误:断言失败! 堆栈回溯: [C]:? [C]:在函数“断言”中 ?: 在函数“getOrCreateTable”中 ?: 在函数“addEventListener”中 ?: 在函数“addEventListener”中 C:\Users\Evan\Desktop\lua\test game\main.lua:337:在主块中
I've been trying to write out a custom tick using the Corona SDK (using Lua). The key seems to be these "eventListeners," but I'm also trying to get them to work with classes. right now i have this class "World" set up. I'm trying to add an EventListener to my "tick" function, but Corona is telling me I can't do it.
function World:tick()
--player:tick()
--camera:tick(player.x,player.y)
--for i=0,monsters.length do
-- monster[i]:tick()
if(rwalk) then
mainGroup.x = mainGroup.x-10
elseif(lwalk) then
mainGroup.x = mainGroup.x+10
end
end
Runtime:addEventListener("enterFrame",tick)
Error: Runtime error: assertion failed!
stack traceback:
[C]: ?
[C]: in function 'assert'
?: in function 'getOrCreateTable'
?: in function 'addEventListener'
?: in function 'addEventListener'
C:\Users\Evan\Desktop\lua\test game\main.lua:337: in main chunk
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用。应该对你有用:
你所缺少的只是使用
World.tick
而不是tick
来指定函数。This works for me. Should work for you:
All you were missing was to specify the function using
World.tick
instead oftick
.