如何修复字体绘图本身



所以我在Microsoft Visual Studios中遇到了问题,我也在使用Monogame,分数会自己画出来,即0与5混合等等。想知道是否有人可以解决这个问题。下面列出了我的代码。

    protected override void Draw(GameTime gameTime)
    {
        // TODO: Add your drawing code here
        timer += gameTime.ElapsedGameTime.TotalMilliseconds; // Increment the timer by the elapsed game time.
        if (timer >= 10000) // Check to see if ten seconds has passed.
        {
            score += 5; // Increment the score by 5.
            timer -= 10000; // Reset the timer.
        }
        spriteBatch.Begin();
        spriteBatch.DrawString(font, "Score: " + score, new Vector2(50, 70), Color.DarkRed);
        spriteBatch.DrawString(font, "Time Elapsed", new Vector2(50, 50), Color.GhostWhite);
        spriteBatch.End();
        base.Draw(gameTime);
    }

您可以在抽奖之间清除屏幕,将此行放在开头;

protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.Clear(Color.CornflowerBlue);   // Clear screen
    ....

最新更新