Hi again,
so, i’m having some trouble with modular coding approach for my game and thats why i have a little question:
how to properly add an eventListener to object in module? Where do i need to put it for object to listen for touches?
any help is great)
[lua]ocal dog = {}
local dog_mt = { __index = dog } – metatable
– PRIVATE FUNCTIONS
local function getDogYears( realYears ) – local; only visible in this module
return realYears * 7
end
– PUBLIC FUNCTIONS
function dog.new( name, ageInYears ) – constructor
local newDog = {
name = name or “Unnamed”,
age = ageInYears or 2
}
return setmetatable( newDog, dog_mt )
end
function dog:rollOver()
print( self.name … " rolled over." )
end
function dog:sit()
print( self.name … " sits down in place." )
end
function dog:bark()
print( self.name … " says “woof!”" )
end
function dog:printAge()
print( self.name … " is " … getDogYears( self.age ) … " in dog years." )
end
return dog[/lua]
and how can i declare coordinates for this object? [import]uid: 16142 topic_id: 18381 reply_id: 318381[/import]