There isn’t enough info in your post to tell exactly what you are trying to accomplish, but this is a generic approach I would use to make a constructor function in a separate module:
in a file ‘popcorn.lua’ write something like this (pseudo code-not tested):
local mod = {};
function mod.new(num)
--this is the function that creates a new popcorn 'class'
local popcornGroup = display.newGroup();
local txt = display.newText(num,0,0,native.systemFont,12);
popcornGroup:insert(txt);
end
return mod;
in ‘Main.lua’, or any other file in your project:
[code]
local pop = require “popcorn”;
local popcorn1 = pop.new(100);
local popcorn2 = pop.new(450);
popcorn1.x , popcorn1.y = display.contentWidth*.5 , display.contentWidth*.5;
popcorn2.x , popcorn2.y = display.contentWidth*.5 , display.contentWidth*.5 + 50;
[/code] [import]uid: 33608 topic_id: 22665 reply_id: 90399[/import]