我正在开发一款游戏,其中一个级别正在解决一个混乱的单词。字母是像瓷砖一样的图像,我试图点击一个字母,这将移动到第一个分配的点,以解决这个词或实际拖动瓷砖到现场。任何人都可以帮我实现吗?
答案 0 :(得分: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)