0

我正在开发一款游戏,其中一个关卡是解决一个混乱的单词。这些字母是像瓷砖一样的图像,我试图单击一个字母,这将移动到分配的第一个位置以解决单词或实际将瓷砖拖到该位置。谁能帮我实现这个?

4

1 回答 1

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)
于 2012-12-15T18:56:54.123 回答