English 中文(简体)
Corona “准”问题——增加
原标题:Corona "tick" issues - addEventListener

我曾试图用Corota SDK(使用Lua)书写习惯。 关键似乎是这些“生计者”,但我也试图让他们与班级合作。 现在,我们就建立了这一类“世界”。 我试图在我的“标准”职能中增加一个活动——但验尸告诉我,我可以这样做。

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:UsersEvanDesktoplua est gamemain.lua:337: in main chunk

最佳回答

This works for me. Should work for you:

World = {}

function World:tick()
    print "Hello!"
end

display.setStatusBar(display.HiddenStatusBar)
Runtime:addEventListener("enterFrame", World.tick)

All you were missing was to specify the function using World.tick instead of tick.

问题回答

暂无回答




相关问题
Listen for Events from Browser "Find" Window in JavaScript

Is there a way to listen for typing into the browser s "find" window in JavaScript? (source: apple.com) I d like to be able to reinterpret the search text from JavaScript. What do I need to ...

Equivalent of PreviewKeyDown of C# needed for native C++/MFC

I used a ActiveXControl in a C# Forms application and had the possibility to implement a PreviewKeyDown event handler for that ActiveXControl. That was needed to specify that, e.g. the [ALT] key, is ...

Refresh the UI in gwt

I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I ...

How to remove "onclick" with JQuery?

PHP code: <a id="a$id" onclick="check($id,1)" href="javascript:void(0)" class="black">Qualify</a> I want to remove the onclick="check($id,1) so the link cannot be clicked or "check($id,...

热门标签