0

私はゲームを開発しており、1 つのレベルでごちゃごちゃした単語を解いています。文字はタイルのような画像であり、文字をクリックすると、割り当てられた最初のスポットに移動して単語を解決するか、実際にタイルをスポットにドラッグしようとしています。誰でもこれを実装するのを手伝ってもらえますか?

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 に答える