我有這樣的代碼:動畫在XNA
public class Area
{
Texture2D point;
Rectangle rect;
SpriteBatch _sB;
GameTimer _gt;
int xo, yo, xt, yt;
//List<Card> _cards;
public Area(Texture2D point, SpriteBatch sB)
{
this.point = point;
this._sB = sB;
xt = 660;
yt = 180;
xo = 260;
yo = 90;
}
public void Draw(SpriteBatch spriteBatch)
{
rect = new Rectangle(660, 180, 80, 120);
spriteBatch.Draw(point, rect, Color.White);
_gt = new GameTimer();
_gt.UpdateInterval = TimeSpan.FromSeconds(0.1);
_gt.Draw += OnDraw;
}
private void OnDraw(object sender, GameTimerEventArgs e)
{
this.pass(xo, yo);
if (xo != xt) xo += (xt > xo) ? 10 : -10;
if (yo != yt) yo += (yt > yo) ? 10 : -10;
}
public void pass(int x, int y)
{
rect = new Rectangle(x, y, 80, 120);
_sB.Draw(point, rect, Color.Black);
}
}
所以,我不明白什麼是錯的。這是我與XNA的第一個項目,因爲它可以有一個愚蠢的錯誤:)
P.S.抱歉。有一個座標爲(xt,yt)的矩形,我需要動畫將矩形移動到(xo,yo)
P.P.S.我補充完整的課程,因爲我不明白我的錯誤。
我們也不明白是什麼錯,因爲你不解釋應該發生什麼以及發生了什麼! – 2012-04-08 19:38:10