【发布时间】:2014-09-03 11:34:04
【问题描述】:
我有以下代码:
function scene:create( event )
local sceneGroup = self.view
-- Initialize the scene here.
-- Example: add display objects to "sceneGroup", add touch listeners, etc.
local options1 = {
x = display.contentWidth / 2,
y = 200,
onRelease = button,
lableAlign = "center",
emboss = true,
id = "1",
label = "Button1"
}
local options2 = {
y = 300,
x = display.contentWidth / 2,
onRelease = button,
lableAlign = "center",
emboss = true,
id = "2",
label = "Button2"
}
local button1 = widget.newButton(options1)
local button2 = widget.newButton(options2)
sceneGroup:insert(button1)
sceneGroup:insert(button2)
end
当我将此代码放在独立文件(不是场景)中时,按钮会按预期显示。但是现在我将这个独立文件变成了一个场景,由于某种原因,上面的代码在模拟器中没有任何结果。有什么想法吗?
【问题讨论】:
-
我们需要更多代码 - 向我们展示您是如何过渡到场景中的,您是否在新场景中添加了小部件?
-
这是在我的 main.lua 文件中。也许这就是问题所在?
-
是的,这就是问题所在。
-
好的。在下面添加了答案。谢谢。