So I have a class called destroy.
I want to give the destroyer.object (display object) a touch function that decreases the health of the destroyer
QUESTION: How do you implement a touch function with additional arguments? :wacko:
Thanks in advance 
[lua]
–
– Destroyer.lua
–
local Destroyer = {}
local Destroyer_mt = { __index = Destroyer } – metatable
– PRIVATE FUNCTIONS
local function set_referance_point(object,x,y)
object:setReferencePoint(display.CenterReferencePoint);
object.x=x;
object.y=y;
end
local function make_money(money, income_rate)
money = money + income_rate
print(money);
end
local function got_touched( event , health)
if(event.phase==“began”) then
print(health)
end
end
– PUBLIC FUNCTIONS
function Destroyer.new(x,y) – constructor
local newDestroyer =
{
Health = 100,
money = 1000,
income_rate=5,
object = display.newImage( “deathstar.png” )
}
set_referance_point(newDestroyer.object,x,y) – positions the Destroyer
local temp_touch_function = function() got_touched(“touch”, newDestroyer.Health) end
newDestroyer.object:addEventListener( “touch”, temp_touch_function )
local temp_money_timer = function() make_money(newDestroyer.money, newDestroyer.income_rate) end
timer.performWithDelay( 500, temp_money_timer, -1) – gives Destroyer a runtime funciton
return setmetatable( newDestroyer, Destroyer_mt )
end
function Destroyer:print_confirmation()
print( “Destroyer Has been created” )
end
return Destroyer
[/lua]