2011-07-15 7 views
0

私はWindows XP SP3を持っています。XNA 3.1遅い動き

私は、バージョン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); 
    } 
} 

を!しかし、動きは非常に遅いです、それはちらつき、私はそれを見ることもできません。 私はそれをいくつかのフラッシュゲームと比較すると比類のないものです。どうしてこれなの?私は間違って何をしていますか?

+1

XNA 4.0がしばらく出てきて、あなたが今使用してしなければならないものですしている注意してください。 –

+0

私はあなたのコードをテストしましたが(XNA 4のVistaでも)、どんな種類のちらつきや吃音も遅れもありませんでした(そして、XPとXNA 3.1のどちらにもないと思います)。あなたは、GPUで加速されたゲームを通常、ラグフリーでプレイすることができますか?投稿していないコードはありますか? –

+0

XPとVistaの間でXNAを実行しているのと後で違いがないことは間違いありませんか?私はこのPC上でゲームをプレイしたことはありません..はい、それは投稿された完全なコードです。私はGPUにアクセスするためにいくつかのドライバ/ライブラリが欠けている可能性がありますか?とにかく、このような単純な例は、CPUによって円滑にエミュレートされる必要がありますか、間違っていますか? –

答えて

1

あなたがRectangleのX成分とY成分を使用しているため、計算は最も近い整数に丸められます。この場合細かい、正確な動きが必要です。

すなわち

Vector2 position = new Vector2(0.1f, 0.1f); 
//Some Arbitrary movement 
float speed = 0.008f; 
position.X += (float)((speed * position.X); 
position.Y += (float)((speed * position.Y); 

spriteBatch.Begin(); 
spriteBatch.Draw(textureTrain, position, rectangle, Color.White); 
spriteBatch.End(); 
+0

デフォルトでは、XNAは描画メソッドをスキップしてラグを補うので、人々がこれを示唆すると私は気になります。ゲームを一定のタイムステップで実行していない限り、これを行う必要はありません。 –

+0

私は自分の答えを変えて、それがより正確であることを期待していますか? –

+0

IsFixedTimeStepとは何ですか?それは動きの流暢さに影響を与えますか? –

関連する問題