public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            if (_particles == null)
                return;

            if (s_defaultTexture == null)
                s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white");

            Texture2D myTexture = _spriteTextures[_spriteCurrentFrame];
            if (myTexture == null)
                myTexture = s_defaultTexture;

            // Render all of our particles.
            aBatch.Begin();
            for (int i = 0; i < _maxParticlesAlive; ++i)
            {
                if (_particles[i]._age < 0.0f)
                    continue;

                Vector2 screenPos = aCamera.WorldToScreen(_particles[i]._pos);
                Vector2 currentSize = Size * _particles[i]._scale;
                Vector2 screenSize = aCamera.WorldSizeToScreenSize(currentSize);
                Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y);

                aBatch.Draw(myTexture, destRect, null, _particles[i]._color, _particles[i]._rotation,
                   new Vector2(myTexture.Width / 2, myTexture.Height / 2), SpriteEffects.None, 0.0f);
            }
            aBatch.End();
        }
Beispiel #2
0
        public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            // TODO: Rendering needs refactoring... a LOT.
            if (s_defaultTexture == null)
                s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white");

            Texture2D myTexture = _spriteTextures[_spriteCurrentFrame];
            if(myTexture == null)
                myTexture = s_defaultTexture;

            Vector2 screenPos = aCamera.WorldToScreen(Position);
            Vector2 screenSize = aCamera.WorldSizeToScreenSize(Size);
            Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y);

            aBatch.Begin();
            aBatch.Draw(myTexture, destRect, null, Color, MathHelper.ToRadians(Rotation),
               new Vector2(myTexture.Width / 2, myTexture.Height / 2), SpriteEffects.None, 0.0f);
            aBatch.End();
        }
        public void Render(Color aColor, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            if (s_defaultTexture == null)
                s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white");

            Vector2 screenPos = aCamera.WorldToScreen(Centroid());
            Vector2 screenSize = aCamera.WorldSizeToScreenSize(Max - Min);
            Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y);

            aBatch.Begin();
            aBatch.Draw(s_defaultTexture, destRect, null, aColor, 0.0f,
               new Vector2(s_defaultTexture.Width / 2, s_defaultTexture.Height / 2),
               SpriteEffects.None, 0.0f);
            aBatch.End();
        }