Search Results

Search found 1 results on 1 pages for 'cromanium'.

Page 1/1 | 1 

  • How do I retain previously drawn graphics?

    - by Cromanium
    I've created a simple program that draws lines from a fixed point to a random point each frame. I wanted to keep each line on the screen. However, it always seems to be cleared each time it draws on the spriteBatch even without GraphicsDevice.Clear(color) being called. What seems to be the problem? protected override void Draw(GameTime gameTime) { spriteBatch.Begin(); DrawLine(spriteBatch); spriteBatch.End(); base.Draw(gameTime); } private void DrawLine(SpriteBatch spriteBatch) { Random r = new Random(); Vector2 a = new Vector2(50, 100); Vector2 b = new Vector2(r.Next(0, 640), r.Next(0,480)); Texture2D filler= new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color); filler.SetData(new[] { Color.Black }); float length = Vector2.Distance(a, b); float angle = (float)Math.Atan2(b.Y - a.Y, b.X - a.X); spriteBatch.Draw(filler, a, null, Color.Black, angle, Vector2.Zero, new Vector2(length,10.0f), SpriteEffects.None, 0f); } What am I doing wrong?

    Read the article

1