displaygroup as metatable "class"?

Is there any way to return a displaygroup as the object of a metatable “class” module?

i went with this in the end

main.lua
[lua]local MenuCreator = require(“MenuCreator”)
local mc = MenuCreator:new() – creates “class” object
local menu = MenuCreator:create(“main”) – returns display object

menu.x=100
menu.y=50[/lua]

MenuCreator.lua
[lua]module(…, package.seeall)
MenuCreator = {}
MenuCreator_mt = (__index=MenuCreator)

function MenuCreator::new()

local self = {}
setmetatable(self, MenuCreator_mt)

return self

end

function MenuCreator::create(id)

local g = display.newGroup()
– graphics stuff etc
g.id = id
return g

end[/lua]

as opposed to

[lua]local MainMenu = require(“MainMenu”)
local menu = MainMenu:new() – no way to return as a displaygroup this way?
menu.x=100
menu.y=50[/lua]

[import]uid: 6645 topic_id: 6237 reply_id: 306237[/import]

I haven’t messed with metatable much because I like doing OOP (or at least approximating OOP) without it, but this bit in the docs sounds relevant:
http://developer.anscamobile.com/content/display-objects#Display_Objects_vs._Tables:_A_Technical_Discussion

The second line of that link specifically states “you cannot set the metatables of display objects.” doh [import]uid: 12108 topic_id: 6237 reply_id: 21547[/import]

oops time to tell myself to RTFM :slight_smile:

thanks. [import]uid: 6645 topic_id: 6237 reply_id: 21590[/import]