私は次のコードでやっています.samosarectは右から左にある速度で来る1つのオブジェクトです(ループごとに10pxと仮定します).tangrectは私のプレーヤーの舌で、幅が200まで増加し、再び0まで減少します。真であり、シュートボタンを押すと舌のブール値が真になります。したがって、私の問題は、プレーヤー(舌直角)がサモサを食べない(サモサレクと交差しない)ことがあることです(長方形が交差していることを目で見ますが、コードはそうではありません)それを取得する)、時々(適切なアニメーションと交差する)問題なくサモサを食べます。
if (Texture.samosarect.Contains(Texture.tonguerect) || Texture.tonguerect.Intersects(Texture.samosarect) && tongue)
{
Texture.tonguerect.Y = -50;
System.Diagnostics.Debug.WriteLine("eated samosaaa");
Texture.samosarect.X = -400;
eateds = true;
jumpframe = 17;
tonguereached = true;
caught = true;
if (MainPage.togkey == 1)
eateffect.Play();
if (!catchedd)
{
score += 30; catched++; catchedd = true;
showpoint = true;
}
else { catchedd = false; }
}