示例#1
0
        private void screen_SpriteChanged(object sender, SpriteChangedEventArgs e)
        {
            RenderTarget2D render = new RenderTarget2D(GraphicsDevice, map.Width, map.Height);

            GraphicsDevice.SetRenderTarget(render);
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin();
            if (back != null)
            {
                spriteBatch.Draw(back, new Rectangle(0, 0, map.Width, map.Height), Color.White);
            }
            //int w = e.Sprite.Width;
            //int h = e.Sprite.Height;
            int w = tileW;
            int h = tileW;

            Color[] c = new Color[e.Sprite.Width * e.Sprite.Height];
            e.Sprite.GetTexture().GetData <Color>(c);
            Color newColor = AverrageColor(c);

            newColor = TintTo(newColor, e.Sprite.Color);
            spriteBatch.Draw(texture, new Vector2(e.Index.X * w * scaleFactor.X, e.Index.Y * h * scaleFactor.Y), null, newColor, 0, Vector2.Zero, scaleFactor * World.TileW, SpriteEffects.None, 0);
            spriteBatch.End();
            GraphicsDevice.SetRenderTarget(null);
            back = render;
        }
示例#2
0
        private void OnSpriteChanged(SpriteChangedEventArgs e)
        {
            EventHandler <SpriteChangedEventArgs> spriteChanged = SpriteChanged;

            if (spriteChanged != null)
            {
                spriteChanged(this, e);
            }
        }