如何使用导演班

时间:2011-06-10 08:49:55

标签: corona

嘿,我是电晕的初学者。我很困惑在我的第一个游戏中使用导演类并且它没有工作。有一个问题我想要整理出来。我可以将这些插入本地组????它是我的第一个应用程序所以请帮助我

   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

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