2012-12-14 35 views
0

我正在開發一款遊戲,一個級別正在解決混亂的單詞。這些字母是像瓷磚的圖像,我想要點擊一個字母,這將移動到第一個分配點以解決單詞或實際將瓷磚拖到現場。任何人都可以幫我實施這個嗎?電暈拖放容器上的物體或參考

+0

你願意發佈一些你正在嘗試的示例代碼嗎? – Lenin

回答

0

要拖動對象請參見本教程:

http://www.coronalabs.com/blog/2011/09/24/tutorial-how-to-drag-objects/

如果你只是想挖掘他們,讓他們移動到您想要的地方,那麼這樣的事情可能會爲你工作:

local function moveTile(event) 
    -- put your code here to move the tile 
    -- figure out the X, Y where the tile needs to move to 
    -- either just set the X, Y on the tile or use a transition.to() call 
    -- to animate it. 
    local thisTile = event.target 
    thisTile.x = destinationX -- you have to figure out what destinationX is. 
    thisTile.y = destinationY -- figure this out too 
    return true 
end 

然後在每瓦創建後,只需添加這條線,使其可點擊:

tile:addEventListener("tap", moveTile) 
+0

感謝羅布,這對我很好,我想我會用這個來代替拖動。 – Gooner