我正在嘗試在Lua中製作類似於糖果粉碎的遊戲。下面是代碼:在Lua(Corona SDK)中擁有一個圖像ID
local images = {
"images/beer.png",
"images/beef.png",
"images/canned_food.png",
"images/cup_ice_cream.png",
"images/french_fries.png",
"images/pepper.png"
}
local rowcount = 8
local colcount = 4
local blockWidth = display.contentWidth/(colcount*4)
local blockHeight = display.contentWidth/(rowcount*2)
local row
local col
local pan = 3
for row = 1, rowcount do
for col = 1, colcount do
local x = (col - 1) * blockWidth + pan
local y = (row + 1) * blockHeight + pan
local block = display.newImage(images[math.random(1, 6)], x, y)
block:addEventListener("touch", blockTouch)
end
end
我需要知道哪個圖像移動的,要知道如果與他們在一條線上做3的新位置。
所以我的問題是,我怎麼能有一個id或標識符來知道用戶在表中移動哪個圖像?
感謝您的幫助