Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ClipTest extends Group {
- class ClipImage extends Image {
- public ClipImage(Texture texture) {
- super(texture);
- }
- @Override
- public void draw(SpriteBatch batch, float parentAlpha) {
- Rectangle scissors = new Rectangle();
- Rectangle clipBounds = new Rectangle(getX(), getY(), getWidth() * 0.75f, getHeight());
- ScissorStack.calculateScissors(
- getStage().getCamera(),
- getStage().getGutterWidth(),
- getStage().getGutterHeight(),
- getStage().getCamera().viewportWidth,
- getStage().getCamera().viewportHeight,
- batch.getTransformMatrix(),
- clipBounds, scissors);
- if (ScissorStack.pushScissors(scissors)) {
- super.draw(batch, parentAlpha);
- ScissorStack.popScissors();
- }
- }
- }
- Image background, foreground;
- public ClipTest() {
- setSize(100, 30);
- background = new Image(G.assets.textureSolidBlack);
- background.setSize(getWidth(), getHeight());
- addActor(background);
- foreground = new ClipImage(G.assets.textureSolidWhite);
- foreground.setSize(getWidth(), getHeight() +10);
- foreground.getColor().a = 0.75f;
- addActor(foreground);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement