2012-03-23 13 views
0

私は単語検索ゲームを作成しようとしています(Wordamentのようなものですが、もっと簡単です)。ジェスチャーと四角形

spriteBatch.DrawStringを使用してテキスト(ジャンパー)を表示しています。次に、文字の上に長方形を描き、長方形の中の単語を読んでいきます。

私の最初の問題は、フリードラッグジェスチャーを使って長方形を描こうとしています。私は描画矩形のいくつかの例を試しましたが、それらはすべて "描画"メソッドにあります。 HandleTouchInputメソッドではありません(ジェスチャーを処理するこのメソッドが見つかりました)。

私の質問には2つの部分があります。

  1. 私は上記の目的を達成できますか? spriteBatch.DrawStringと長方形を使用して、選択された文字を読み取りますか?
  2. もしそうなら、どのようにジェスチャーを使って長方形を描くのですか?

例や提案がありましたら教えてください。

ありがとうございます!

答えて

1

通常、HandleTouchInputメソッドでは何も描画しません。代わりに、入力を処理し、後でスプライトバッチに描画する新しいスプライトを作成します。次の疑似コードのようなもの:

HandleTouchInput(vector2d begin, vector2d end) 
{ 
    sprite tempRectangle = new Rectangle(begin, end); 
    string foundLetters; 
    //search through the letters in your puzzle to find which ones were selected in the rectangle 
    foreach(letter in wordPuzzleSprites) 
    { 
     //if you found one, then add it to the list of letter that were selected 
     if(letter.isWithin(tempRectangle)) 
     { 
      foundLetters.add(letter.letterCharacter()); 
     } 
    } 
    //check your found letter against the list of words 
    foreach(word in wordPuzzleList) 
    { 
     if(foundLetters == word) 
     { 
      //mark the word as found, and add the rectangle sprite to the collection of sprites to be drawn 
      CollectionOfSprites.add(tempRectangle); 
     } 
    } 
} 
関連する問題