【发布时间】:2014-04-05 20:40:00
【问题描述】:
我正在使用以下代码,其中 samosarect 是一个以一定速度从右到左的对象(假设每个循环 10 像素),舌头矩形是我的玩家的舌头,宽度增加到 200,然后再次减小到 0。只有舌头当舌头为真时增加,当我按下射击按钮时,舌头布尔值变为真。所以我的问题有时是我的玩家(舌头)不吃(不与 samosarect 相交)samosa(我用我的眼睛看着矩形相交但我的代码没有得到那个),有时它(与适当的动画相交)吃samosa没有任何问题。
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; }
}
【问题讨论】: