我在XP上使用C#2010 .net 4.0。game.microsoft.Xna.Framework不工作在C#
我使用gameTime得到一個錯誤,其計算方法如下:名稱「gameTime」不會在目前情況下
存在我已經下載(xnafx40_redist.msi),並加入Microsoft.Xna從參考.Framework,並用它在我的代碼:
using System;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int counter = 1;
int limit = 50;
float countDuration = 2f;
float currentTime = 0f;
//Error on gameTime
currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (currentTime >= countDuration)
{
counter++;
currentTime -= countDuration;
}
if (counter >= limit)
{
counter = 0;
}
}
}
}
我也試圖聲明GameTime變量,但它也超出範圍。 這與我複製的XNA框架有關嗎?或XP?或.net版本?代碼是否需要一個對象或其他東西?我是XNA解決方案的新成員。
附加信息:似乎「遊戲」時,我用其他的代碼申報Microsoft.Xna.Framework.Game也不能正常工作。這是說類型或命名空間'遊戲'不存在。
在XNA中我很新,我看到Stack中的代碼表明它是用C#編寫的定時器的可行精確解決方案。我沒有意識到我需要將實際的遊戲與可變的gameTime連接起來。你的鏈接幫助了很多麻煩。 –