Hi guys,
I am trying to implement a class called key… it works fine… but i need to know how to get the x position and y position of the object.
Also how can I add event listeners
code for key.lua
[code]
local key = {}
local key_mt = { __index = key}
function key.new(startX, startY ) – constructor
local keyWidth = 25
local keyHeight = 30
local charImage = “items/img/key.png”
local key = display.newImageRect(charImage, keyWidth, keyHeight)
key.x = startX
key.y = startY
physics.addBody(key, “static”)
return setmetatable( key, key_mt )
end
function key:getX()
print(key.x)
end
– would i add collision event handlers here?
return key
[/code] [import]uid: 67619 topic_id: 20696 reply_id: 320696[/import]