MujjinGun
MujjinGun

Reputation: 490

Libgdx blending two masks?

Screen is splitted to two sections and i have two groups of textures.

I want to make each texture group cropped to fit each section of the screen. How to make this happen using blending(masks)?

Here is a image I made with MSPaint to describe the situation: description image

Upvotes: 1

Views: 292

Answers (1)

Tenfour04
Tenfour04

Reputation: 93609

I don't know how to do it with blending masks, but you can do it with scissor tests.

private Rectangle leftSide;
private Rectangle rightSide;

public void resize (int width, int height) {
    //...

    leftSide = new Rectangle(0, 0, width/2, height);
    rightSide = new Rectangle(width/2, 0, width/2, height);
}

public void render() {

    //...

    spriteBatch.begin();
    //draw background

    spriteBatch.flush();
    ScissorStack.pushScissors(leftSide);
    //draw left side stuff that is cropped
    spriteBatch.flush();
    ScissorStack.popScissors();
    ScissorStack.pushScissors(rightSide);
    //draw right side stuff that is cropped
    spriteBatch.flush();
    ScissorStack.popScissors();
    //draw any other stuff that is not cropped on top of everything else
    spriteBatch.end();
}

Upvotes: 2

Related Questions