1
votes

I have a number of square regions in my game screen which, when actors move across these regions, I want the background image to show through from behind.

So, is it possible to draw to a SpriteBatch such that a region is subtracted/deleted from the texture (effectively "punching a hole" in it)?

I can't think how else to achieve this... Scissors seem incredibly impractical for my purpose, as I want to clip the areas INSIDE a number of squares. This is the inverse of Scissors - which clip areas OUTSIDE the scissors' bounds. The thought of calculating dozens of Scissor regions to fill the inverse areas between an assortment of square regions seems too impractical to be the solution... especially if the regions are moving.

Any help or suggestions appreciated!

UPDATE: Image attached.

I want the background to always be visible in the areas marked with the dotted lines. The dotted areas will move, so I'd rather not create more sprites from the background to lay on top, but rather have parts of the actors intersecting the dotted squares not be drawn. (Or any method that will achieve the same effect.)

https://imagizer.imageshack.us/v2/596x523q90/842/8xp1.png

1
Can you add a before/after picture to make what you're asking for clearer?P.T.
I've added an image to illustrate what I'm after, thanks P.T.Bumpy

1 Answers

0
votes

I think the best hack is to not try and be so precise about clipping your actors, but to just re-draw the background on top the actors (and to clip that).

Specifically:

  1. draw the whole background
  2. draw your actors/sprites
  3. draw the background with one cliprect for one part that "shows through"
  4. draw the background with another cliprect for the other part that "shows through"
  5. draw the dotted boxes around your cliprect areas

Great image, by the way. Easily worth 1000 words. :)