public void Draw(SpriteBatch spritebatch, Camera camera, Texture2D texture) { int i; for (i = 0; i < maxParticles; i++) { particles[i].Draw(spritebatch, camera, texture); } }
/// <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); Camera camera = new Camera(GraphicsDevice.Viewport); view = new drawView(spriteBatch, Content, camera); // TODO: use this.Content to load your game content here }
// en konstruktor som laddar in först i klassen! public drawView(SpriteBatch spritebatch, ContentManager Content, Camera camera) { timer = 0; this.spritebatch = spritebatch; this.camera = camera; particle = Content.Load<Texture2D>("spark");//laddar in spark //detta görs bara en gång! timerForNewParticles(); }
//ritar ut texturen med farten och en färg! internal void Draw(SpriteBatch spriteBatch, Camera camera, Texture2D texture) { //spriteBatch.Draw(texture, camera.scaleParticles(position.X, position.Y), Color.White); spriteBatch.Draw(texture, camera.scaleParticles(position.X, position.Y), null, Color.White, 0f, Vector2.Zero, 0.1f, SpriteEffects.None, 0f);//denna skalar om mina partiklar! }