Displaying broken sprites?

I am completely new to the world of 2D engines. I figured out how to upload images and display them as sprites and stuff, but there is one question that bothers me. For example, when a "rocket" hits an object, it deals damage to it and leaves the crater behind. I would like the crater to show at this facility. This will require skipping some pixels of this image when rendering, right? My question is: how would you do this? What information would you use to save this? How to display a "broken" sprite?

+3
source share
6 answers

Create a sprite sheet .

, . , , ..

, , . , . , , X Y . , , , , .

+3

. , .

+2

, XNA, , API ( OpenGL/D3d ). , RenderState. RenderState , ( AlphaSourceBlend AlphaDestinationBlend RenderState, , ).

, RenderState GetTexture().

, , SpriteBatch "" ( XNA, , ), reset .

+1

, , , .

public static void Fill(this Texture2D t, Func<int, int, Color> perPixel)
        {
            var data = new Color[t.Height * t.Width];
            for (int y = 0; y < t.Height; y++)
                for (int x = 0; x < t.Width; x++)
                {
                    data[x + (y * t.Width)] = perPixel(x, y);
                }
            t.SetData(data);
        }
0

- Java-, / ( GunBound).

, . , . , , blitting transparent hit testing.

, " " .

, , . , , .

0

Source: https://habr.com/ru/post/1736285/


All Articles