local tree = {}
tree[1] = display.newImage( "Palm-arecaceae.png" )
tree[1].xScale = 0.7; tree[1].yScale = 0.7
tree[1]:setReferencePoint( display.BottomCenterReferencePoint )
tree[1].x = 20; tree[1].y = baseline + 40
tree[1].dx = 0.1
tree[2] = display.newImage( "Greenhouse-Palm-jubaea01.png" )
tree[2].xScale = 0.6; tree[2].yScale = 0.6
tree[2]:setReferencePoint( display.BottomCenterReferencePoint )
tree[2].x = 120; tree[2].y = baseline + 40
tree[2].dx = 0.2
答案 0 :(得分:0)
我认为您只需要替换代码的第一行。
local tree = {}
创建一个通用表,DisplayObject是特殊表,您可以使用:
创建它们 local tree = display.newGroup()
希望这有帮助
答案 1 :(得分:0)
您可以创建本地组并逐个插入它们,如下所示:
local localGroup = display.newGroup()
local tree = {}
tree[1] = display.newImage( "Palm-arecaceae.png" )
tree[1].xScale = 0.7; tree[1].yScale = 0.7
tree[1]:setReferencePoint( display.BottomCenterReferencePoint )
tree[1].x = 20; tree[1].y = baseline + 40
tree[1].dx = 0.1
tree[2] = display.newImage( "Greenhouse-Palm-jubaea01.png" )
tree[2].xScale = 0.6; tree[2].yScale = 0.6
tree[2]:setReferencePoint( display.BottomCenterReferencePoint )
tree[2].x = 120; tree[2].y = baseline + 40
tree[2].dx = 0.2
for i = 1, #tree do
if(tree[i] ~= nil)then
localGroup:insert(transTable[i]))
end