【发布时间】:2012-10-01 14:18:35
【问题描述】:
我有一个这样的类作为例子:
--An External Library --UI.lua
UI = {}
function UI: new()
local Group = display.newGroup;
local inventory_frames = display.newImage("inventorybox.png") ;
Group :insert( inventory_frames) ;
function inventory_framesDown()
local tr_down = transition.to(inventory_frames,{time = 150,alpha = 0, x=0 ,y =8})
end
return Group
end
return UI
现在来自 corona 的实际 scene.lua(使用故事板 API)。
1.local ui=需要“UI.lua” 之后在我的创建场景函数中()(我没有把它放在组场景中的原因是因为我想让它手动消失)
local UI2 = UI:new()
然后在我的退出场景函数中。我想从 UI:new() 中调用函数 inventory_framesDown()。
function scene:exitScene(e)
invent = UI:new() inventory_framesDown() --this dose not work
storyboard.purgeScene("scene2");
storyboard.removeAll()
end
那么如何从外部库调用全局函数内的全局函数呢? 在此先感谢:)
【问题讨论】:
-
玩了很多之后,我想通了
-
我在您的代码中看到了
UI:function new()。这不是有效的 Lua 语法。你的意思是function UI:new()吗?问一个关于甚至没有编译的代码的问题,可以最大限度地降低得到一个好的答案的可能性。 -
谢谢,是的,我做到了,我刚刚修好它。这些都是保持清醒的迹象;)