// draw the particleExplosion public void Draw(SpriteBatch spriteBatch, Camera camera, Texture2D particleTexture) { for (int i = 0; i < numberOfParticles; i++) { particles[i].Draw(spriteBatch, camera, particleTexture); } }
public void Draw(SpriteBatch spriteBatch, Camera cam, float elapsedTime) { frameCount++; if (frameCount <= 32) { goneTime += elapsedTime; if (goneTime > explosionTime) { goneTime = 0; } float animatedTime = goneTime / explosionTime; frame = (int)(animatedTime * numberOfFrames); frameX = frame % xframes; frameY = frame / xframes; spriteBatch.Begin(); spriteBatch.Draw(explosionTexture, camera.getScreenCord(currentPos), new Rectangle((int)(expWidth * frameX), (int)(expHeight * frameY), (int)expWidth, (int)expHeight), Color.White, 0, new Vector2(expWidth / 2, expHeight / 2), scale, SpriteEffects.None, 0); spriteBatch.End(); } }
//construct public SmokeView(SpriteBatch Sprite, Camera camera2, Texture2D particleTexture2) { spriteBatch = Sprite; particleTexture = particleTexture2; camera = camera2; durationTime = 0; systems = new List<ParticleSystem<SmokeParticle>>(); }
public GameView(SpriteBatch Sprite, Camera camera2, Texture2D particleTexture2) { spriteBatch = Sprite; particleTexture = particleTexture2; camera = camera2; durationTime = 0; createParticle(); }
public ExplosionView(Camera camera, SpriteBatch spriteBatch, Vector2 explosionPosition, Texture2D explosionTexture) { this.camera = camera; this.spriteBatch = spriteBatch; this.explosionPosition = explosionPosition; this._explosionTexture = explosionTexture; explosion = new Explosion(_explosionTexture, spriteBatch, camera, explosionPosition); }
public Explosion(Texture2D explosionTexture, SpriteBatch sprite, Camera cam, Vector2 startPos) { this.explosionTexture = explosionTexture; camera = cam; currentPos = startPos; explosionTime = 1000.0f; expHeight = explosionTexture.Height / yframes; expWidth = explosionTexture.Width / xframes; scale = camera.getScale(expWidth, size); }
/// en konstruktor som laddar in först i klassen! public BallView(GraphicsDeviceManager graphics, BallSimulation BallSimulation, ContentManager Content) { ball = Content.Load<Texture2D>("master_ball");///laddar in bollen //detta görs bara en gång! box = new Texture2D(graphics.GraphicsDevice, 1, 1);///denna skapar en box box.SetData<Color>(new Color[] { Color.Black });/// denna sätter vilken färg! camera = new Camera(graphics.GraphicsDevice.Viewport);/// skapar en ny camera instans ballSimulation = BallSimulation; }
public void Draw(float elapsedTime, SpriteBatch spriteBatch, Camera camera, Texture2D smokeTexture) { spriteBatch.Begin(); foreach (ParticleSystem<SmokeParticle> s in systems) { s.Update(elapsedTime); // draw the animation s.Draw(spriteBatch, camera, smokeTexture); } spriteBatch.End(); }
public void Draw(SpriteBatch spriteBatch, Camera cam, float elapsedTime) { goneTime += elapsedTime; if(goneTime >= explosionTime) { goneTime = 0; } float animatedTime = goneTime / explosionTime; frame = (int)(numberOfFrames * animatedTime); frameX = frame / xFrames; frameY = frame % yFrames; spriteBatch.Draw(explosionTexture, cam.getScreenCord(new Vector2(0.5f, 0.5f)), new Rectangle((int)(expWidth * frameX), (int)(expHeight * frameY), (int)expWidth, (int)expHeight), Color.White, 0, new Vector2(expWidth / 2, expHeight / 2), scale, SpriteEffects.None, 0); }
public void Draw(SpriteBatch spriteBatch, Camera cam, float elapsedTime) { scale = cam.getScale(0.7f, explosionTexture.Bounds.Width); goneTime += elapsedTime; if (goneTime >= explosionTime) { goneTime = 2; // time between explosion } float animatedTime = goneTime / explosionTime; // calc for the imageAnimation frame = (int)(animatedTime * numberOfFrames); frameX = frame % xframes; frameY = frame / xframes; // draw the explosion in center spriteBatch.Draw(explosionTexture, cam.getScreenCord(new Vector2(1.0f, 1.0f)), new Rectangle((int)(expWidth * frameX), (int)(expHeight * frameY), (int)expWidth, (int)expHeight), Color.White, 0, new Vector2(expWidth / 2, expHeight / 2), scale, SpriteEffects.None, 0); }
// construct public GameView(SpriteBatch sprite, Camera cam, Texture2D explosionTexture) { camera = cam; spriteBatch = sprite; explosion = new Explosion(explosionTexture); }
internal void Draw(SpriteBatch spriteBatch, Camera camera, Texture2D particleTexture) { Rectangle sparkRectangleTexture = camera.getRectangle(position, radius); spriteBatch.Draw(particleTexture, sparkRectangleTexture, Color.White); }
// draw internal void Draw(SpriteBatch spriteBatch, Camera camera, Texture2D particleTexture) { //Rectangle sparkRectangleTexture = camera.getRectangle(position.X, position.Y); spriteBatch.Draw(particleTexture, camera.getScreenCord(position), null, null, null, 2, Vector2.One * camera.getScale(particleTexture.Width, 0.025f), Color.White,SpriteEffects.None, 0); }