how to use director class
hey i'm beginner to corona . i'm confused alot about using director class in my first game and it didnt work.here is one problem which i want to be sort out.how can i insert these to local group????its my first app so please help me.
local tree = {}
tree[1] = display.newImage( "Palm-arecaceae.png" )
tree[1].xScale = 0.7; tree[1].yScale开发者_JS百科 = 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
i think that you just have to replace the first line of your code.
local tree = {}
creates a generic table, DisplayObject are special tables, you can create them using:
local tree = display.newGroup()
Hope this helps
You can create your localgroup and insert them one by one with for like following:
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
精彩评论