yeah, just use lua tables.
local rects = {}
local myRect = director:createRectangle(x, y, width, height)
table.insert(rects, myRect)
now, if you want to examine all of your rectangles you can just iterate over rects
.
if you absolutely have to store all of your references to rectangles, i'd suggest making a helper method to automate that part for you, something like this maybe:
local rects = {}
function createRect(x, y, width, height)
local rect = director:createRectangle(x, y, width, height);
table.insert(rects, rect)
return rect
end
and then you could just call your helper function and know that each rectangle object it returns to you has automatically been added to your list for later.
local myRect = createRect(1, 1, 1, 1)