我想要程序要做的是在每個出現在.txt文件中的點繪製圖形地面,但是每次運行它時,它都不繪製精靈?幫助渲染精靈
這裏是代碼.....
using (StreamReader sr = new StreamReader("trainingLevel.txt"))
{
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
string[] elements = line.Split(',');
foreach (string e in elements)
{
int id = int.Parse(e);
if (id == 1)
{
CreatePlatform(x, y);
}
x += widthPlatform;
}
y += heightPlatform;
x = 0;
}
}
public void CreatePlatform(int x, int y)
{
groundSprite = new Sprite();
groundSprite.Position = new Vector2(x, y);
groundSprite.Load("Ground", Content, simulator);
groundSprite.IsStatic = true;
groundSprite.Geom.OnCollision += OnCollision;
}
protected override void Draw(GameTime gameTime) {
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
List<Sprite> updateDraw = new List<Sprite>();
foreach (Sprite z in updateDraw) {
simulator.Update(gameTime.ElapsedGameTime.Milliseconds * .001f);
z.Update(gameTime);
spriteBatch.Draw(z.CurrentTexture, z.Position, null, Color.White, z.Rotation, z.Origin, 1, SpriteEffects.None, 1);
}
spriteBatch.End();
base.Update(gameTime);
base.Draw(gameTime);
}
矢車菊藍?好惡。 – 2010-02-16 00:16:54
您可能想要應用更多標記或至少指示您正在使用的圖形系統。我不承認任何這些對象名稱。 GAPI?的DirectX? – Josh 2010-02-16 00:17:33
@Josh Einstein:我確實;)這是.NET的XNA。如果Sprite的聲明也包含在內,這將有所幫助。 – Skurmedel 2010-02-16 00:18:32