Here is the function that creates the new display group:
[lua]function new()
local group = display.newGroup()
local back = display.newImage(“background.png”)
group:insert(back)
local eqList = tableView.newList{
data = itemList,
callback = function(row)
local itemRect = renderItem(row)
return itemRect
end
}
group:insert(eqList)
return group
end[/lua]
The itemList is a table of objects. Here is the renderItem routine:
[lua]function renderItem( self)
local frameHeight = 48;
local pictureRadius = 24;
local nameMargin = {10,8};
local margin = 24
local textSize = 18
local iSlot = self.iSlot
local iType = self.iType
local width = display.contentWidth-2*margin
local group = display.newGroup()
local frame = display.newRoundedRect( 0, 0, width, frameHeight, 10);
frame:setFillColor( rgb( itemColor[iType] ))
frame:setStrokeColor( 80, 80, 80);
frame.strokeWidth = 2;
group:insert( frame);
local offsetX, offsetY = 5, 1
local circ = display.newCircle( pictureRadius+offsetX, pictureRadius+offsetY, pictureRadius+2)
circ:setFillColor(0,0,0,120)
group:insert(circ)
local disc = display.newImageRect( “disc.png”, pictureRadius*2, pictureRadius*2)
disc.x = pictureRadius+offsetX
disc.y = pictureRadius+offsetY
group:insert( disc);
local image = display.newImageRect( itemImage[iSlot], disc.width*0.7, disc.height*0.7)
image.x = disc.x
image.y = disc.y
group:insert(image)
local itemName = display.newText( self.name, pictureRadius*2 + nameMargin[1], nameMargin[2], nil, textSize)
itemName:setTextColor( rgb( itemTextColor[iType] ))
group:insert(itemName)
return group
end[/lua]
As you can see, the “self” item has several properties for name, color, type, etc. And for each type/slot there are arrays for color and the image name. So I can’t really give *all* the code without making this a huge post that nobody will read. But you can see that I’m just calling normal Corona routines for rectangles, images, text, etc. [import]uid: 12529 topic_id: 7112 reply_id: 25002[/import]