小惑星を避けて画面の周りに宇宙船をドラッグし、長方形が衝突したら船を元の位置に戻すアプリを持っていますが、それは起こっていません。
何が悪いのかわからない...
コード:
//Drag Ship
TouchCollection touchLocations = TouchPanel.GetState();
foreach (TouchLocation touchLocation in touchLocations)
{
Rectangle touchRect = new Rectangle
((int)touchLocation.Position.X, (int)touchLocation.Position.Y, shipRect.Width, shipRect.Height);
if (touchLocation.State == TouchLocationState.Pressed
&& shipRect.Intersects(touchRect))
{
shipPressed = true;
}
else if (touchLocation.State == TouchLocationState.Moved && shipPressed)
{
shipRect.X = touchRect.X - touchRect.Width / 2;
shipRect.Y = touchRect.Y - touchRect.Height / 2;
}
else if (touchLocation.State == TouchLocationState.Released)
{
shipPressed = false;
}
else if (lnBtnPlay.Tapped == true)
{
}
}
コード 2:
if (shipRect.Intersects(asteroid1Rect))
{
shipPosition = new Vector2(10, 400);
}