an easy solution for your problem is creating a function to create rectangles…then just call it and your done you have a rectangle.
local group=display.newGroup() local function createRect(paramsIn) local params=paramsIn or {} local parent=params.parent or nil local width=params.width or 24 local height=params.height or 24 local x=params.x or 0 local y=params.y or 0 local color=params.color or {0,1,0,1} local rect = display.newRect(x, y, width, height ) rect:setFillColor( 0,1,0 ) if parent then parent:insert(rect) end rect:setFillColor(unpack(color)) return rect end local rect=createRect({parent=group, width=50, height=30, color={1,0,0}, x=100, y=100}) local rect2=createRect({parent=group, x=150, y=150})
if you want to copy a table there is this:
https://docs.coronalabs.com/api/library/table/copy.html
but in the case of objects it’s a bad idea to try to copy this way.