从下面的代码中,如何使运行时侦听器运行而不中断我的应用程序的显示部分?目前,当我使用运行时侦听器时,显示速度变慢。仅供参考,我是 Lua/Corona 的新手,也是 stackoverflow 的新手。
function scene:createScene( event )
group2 = scrollView.new{ top=topBoundary, bottom=bottomBoundary }
myImage = display.newImage("imgbg1.png")
myImage.isVisible = true
group2:insert(myImage)
local yval = 120
socket,err=socket1.connect("host", port)
while not err do
socket:settimeout(1)
socket:send("runcommand\r\n")
repeat
line, err = socket:receive()
if line then
no = no + 1
-- [[ get only the main properties ]] --
if no >= 5 then
reply = reply .. line
end
end
until err
t1 = reply
loadnsave:saveToJson(t1,filename)
tsw = loadnsave:loadData(filename)
local i = 0
for k, v in pairs(tsw) do
i = i + 1
print("\n" .. k , v )
locy = locy + 20
imgBase[i] = display.newImage("image.png")
imgBase[i].x = locx
imgBase[i].y = locy
group2:insert(imgBase[i])
sw[i] = swfunc(tsw[k],k,locy,i)
group2:insert(sw[i])
locy = locy + 40 + iHeight
end
inity = 1
initw = 1
end
Runtime:addEventListener("enterFrame", swlistener)
end
function swlistener(event)
local reply2 = ""
repeat
line2, err2 = socket:receive()
if line2 then
reply2 = reply2 .. line2
end
until err2
end