2012-01-17 13 views
0

ここで私はラップタイマーを実装しようとしたところで少し問題があります。XNA 4.0のラップタイマー?

私の保護オーバーライドvoid更新で私はこれを持っています。スタートライン、タイマーが開始されますが、それがない場合は、タイマーは(それだけでstops_秒を追加しないと衝突しているcar2red場合

if ((IntersectPixels(destinationRedRect, car2redTextureData, startingLineRectangle, startingLineTextureData))) 
{ 
    { 
     redHit = true; 
     _timer1 += gameTime.ElapsedGameTime.TotalMilliseconds; 
    } 
} 

私はここで言っている^、。どのように私はそれを作ることができています、car2red場合は、ザ・スターティング・ラインをヒットし、タイマーが継続(始まる行に触れることなく)前方に数ピクセルを移動

ありがとう

答えて

0

あなたはこのような場合は、別のステートメントている必要があります?。

if (redHit) { 
    _timer1 += gameTime.ElapsedGameTime.TotalMilliseconds; 
} 

if ((IntersectPixels(destinationRedRect, car2redTextureData, startingLineRectangle, startingLineTextureData))) 
{ 
    redHit = true; 
    //Only use this line if you want to reset the timer to 0 when the player crosses that line again. 
    _timer1 = 0;// I'm assuming that _timer1 is a double 
} 
関連する問題