【发布时间】:2023-03-12 16:35:02
【问题描述】:
我有 Windows XP SP3。
我在 3.1 版本中创建了默认的 XNA 项目,并将这些简单的行添加到预生成的代码中:
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Rectangle rectangle = new Rectangle(80, 80, 100, 100);
Texture2D textureTrain;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 10);
}
...
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
textureTrain = Content.Load<Texture2D>("MyBitmap1");
}
...
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
rectangle.X = rectangle.X + 1;
rectangle.Y = rectangle.Y + 1;
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
spriteBatch.Begin();
spriteBatch.Draw(textureTrain, rectangle, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
}
就这么简单!但是动作很迟钝,忽闪忽闪,我都不敢看。 如果我将它与一些 Flash 游戏进行比较,它是无与伦比的。为什么是这样?我做错了什么?
【问题讨论】:
-
请注意,XNA 4.0 已经发布了一段时间,您现在应该使用它。
-
我测试了您的代码(尽管是在 XNA 4 中的 Vista 上),没有任何闪烁、卡顿或延迟(我也不希望在 XP 和 XNA 3.1 上出现) )。您是否能够正常畅玩 GPU 加速游戏且无延迟?有没有你没有发布的代码?
-
那么您确定在 XP 和 vista 及更高版本上运行 XNA 之间没有区别吗?我从来没有在这台电脑上玩过游戏。是的,它是发布的完整代码。难道是我错过了一些访问 gpu 的驱动程序/库?反正这么简单的例子一定是cpu能顺利模拟出来的,还是我错了?
标签: xna game-physics