I need to do thing on the pic, to punch holes in one sprite with the shape of multiple other sprites. The positions of those holes varies so I can’t make one mask beforehand.
I just can’t figure out how to “invert” the effect. My code for what I don’t want:
<code>static void drawMaskedSprite(SpriteBatch spriteBatch, Sprite maskedSprite, Sprite[] masks, float x, float y, float width, float height) {
int blendingSrcFunc = spriteBatch.getBlendSrcFunc();
int blendingDstFunc = spriteBatch.getBlendDstFunc();
for (int i=0; i<masks.length; i++) {
Gdx.gl.glColorMask(false, false, false, true);
spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ZERO);
spriteBatch.draw(masks[i], x, y, width, height);
spriteBatch.flush();
Gdx.gl.glColorMask(true, true, true, true);
spriteBatch.setBlendFunction(GL20.GL_DST_ALPHA, GL20.GL_ONE_MINUS_DST_ALPHA);
spriteBatch.draw(maskedSprite, x, y, width, height);
spriteBatch.flush();
}
spriteBatch.setBlendFunction(blendingSrcFunc, blendingDstFunc);
}
</code>
<code>static void drawMaskedSprite(SpriteBatch spriteBatch, Sprite maskedSprite, Sprite[] masks, float x, float y, float width, float height) {
int blendingSrcFunc = spriteBatch.getBlendSrcFunc();
int blendingDstFunc = spriteBatch.getBlendDstFunc();
for (int i=0; i<masks.length; i++) {
Gdx.gl.glColorMask(false, false, false, true);
spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ZERO);
spriteBatch.draw(masks[i], x, y, width, height);
spriteBatch.flush();
Gdx.gl.glColorMask(true, true, true, true);
spriteBatch.setBlendFunction(GL20.GL_DST_ALPHA, GL20.GL_ONE_MINUS_DST_ALPHA);
spriteBatch.draw(maskedSprite, x, y, width, height);
spriteBatch.flush();
}
spriteBatch.setBlendFunction(blendingSrcFunc, blendingDstFunc);
}
</code>
static void drawMaskedSprite(SpriteBatch spriteBatch, Sprite maskedSprite, Sprite[] masks, float x, float y, float width, float height) {
int blendingSrcFunc = spriteBatch.getBlendSrcFunc();
int blendingDstFunc = spriteBatch.getBlendDstFunc();
for (int i=0; i<masks.length; i++) {
Gdx.gl.glColorMask(false, false, false, true);
spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ZERO);
spriteBatch.draw(masks[i], x, y, width, height);
spriteBatch.flush();
Gdx.gl.glColorMask(true, true, true, true);
spriteBatch.setBlendFunction(GL20.GL_DST_ALPHA, GL20.GL_ONE_MINUS_DST_ALPHA);
spriteBatch.draw(maskedSprite, x, y, width, height);
spriteBatch.flush();
}
spriteBatch.setBlendFunction(blendingSrcFunc, blendingDstFunc);
}