コード例 #1
0
        public DummyZSprite(string prefix)
        {
            var gd = GameFacade.GraphicsDevice;

            var alpha = Texture2D.FromFile(gd, prefix + "a.png");
            var pixel = Texture2D.FromFile(gd, prefix + "p.png");
            var depth = Texture2D.FromFile(gd, prefix + "z.png");

            var tex = new Texture2D(gd, pixel.Width, pixel.Height);
            var texData = new Color[pixel.Width * pixel.Height];
            var alphaData = new Color[pixel.Width * pixel.Height];
            var pixelData = new Color[pixel.Width * pixel.Height];

            pixel.GetData(pixelData);
            alpha.GetData(alphaData);

            for (var i = 0; i < texData.Length; i++)
            {
                var pixelPx = pixelData[i];
                var alphaPx = alphaData[i];
                pixelPx.A = alphaPx.R;

                texData[i] = pixelPx;
            }

            tex.SetData(texData);
            pixel.Dispose();
            alpha.Dispose();

            Sprite = new HouseBatchSprite
            {
                Pixel = tex,
                RenderMode = HouseBatchRenderMode.Z_BUFFER,
                Depth = depth,
                SrcRect = new Microsoft.Xna.Framework.Rectangle(0, 0, pixel.Width, pixel.Height),
                DestRect = new Microsoft.Xna.Framework.Rectangle(0, 0, pixel.Width, pixel.Height)
            };
        }
コード例 #2
0
 public void Draw(HouseBatchSprite sprite)
 {
     sprite.DrawOrder = DrawOrder++;
     Sprites.Add(sprite);
 }