1
내가 만든 객체에 attirubute를 추가하려고합니다. 새 객체를 만들었지 만 typeOfBird와 같은 새 attiribute를 추가하고 bird.typeOfBird와 같은 attiributes에 연결하려고합니다. 내가 어떻게 할 수 있니? 그것은 새 개체처럼 보이는루아에서 객체에 속성을 추가하려면 어떻게해야합니까?
module(...,package.seeall)
function new(params)
local bird=display.newImage(params.img,params.x,params.y)
function bird:touch(event)
local t = event.target
local phase = event.phase
if "began" == phase then
-- Make target the top-most object
local parent = t.parent
parent:insert(t)
display.getCurrentStage():setFocus(t)
t.isFocus = true
elseif t.isFocus then
if "moved" == phase then
t.x = event.x
t.y = event.y
elseif "ended" == phase or "cancelled" == phase then
display.getCurrentStage():setFocus(nil)
t.isFocus = false
end
end
return true
end