1
我已經創造了一些循環按鈕和我想要得到那個按鈕是tapped.I已在環路設置屬性名的名稱和標記,這樣我怎麼能在功能selectCurrentColor如何獲取按鈕的名稱和標籤的功能?
這得到了名稱和標記是我的代碼:
for i=1,16 do
coloringSelect[i]=display.newImage("Resources/coloring_01/color" .. i .. ".png")
print("color" .. i .. ".png")
coloringSelect[i]:scale(0.28,0.28)
coloringSelect[i].x=colorx
coloringSelect[i].y=colory
coloringSelect[i].name= "color"..i
coloringSelect[i].tag= i
if i%2==0 then
colorx=40
colory=colory+30
else
colorx=colorx+38
end
stageGroup:insert(coloringSelect[i])
coloringSelect[i]:addEventListener("tap",selectCurrentColor)
end
function selectCurrentColor(self,event)
print(event.tag)
print(self.name)
end