Question

I have this very simple code:

private static final int SKY_COLOR = Color.rgb(161, 210, 241);
private static final int GROUND_COLOR = Color.rgb(171, 131, 35);

@Override
public void init() {

    /* Draw the sky */
    SurfaceImage backgroundTopImage = graphics().createSurface(graphics().width(), graphics().height() / 2);
    backgroundTopImage.surface().setFillColor(SKY_COLOR);
    //--> THE NEXT LINE
    backgroundTopImage.surface().fillRect(0, 0, backgroundTopImage.width(), backgroundTopImage.height());

    ImageLayer backgroundTop = graphics().createImageLayer(backgroundTopImage);
    graphics().rootLayer().addAt(backgroundTop, 0, 0);

    /*Draw the ground */
    SurfaceImage groundBottomImage = graphics().createSurface(graphics().width(), graphics().height() / 4);
    groundBottomImage.surface().setFillColor(GROUND_COLOR);
    PlayN.log().debug("groundBottomImage.height()=" + groundBottomImage.height());
    groundBottomImage.surface().fillRect(0, 0, groundBottomImage.width(), groundBottomImage.height());

    ImageLayer groundBottom = graphics().createImageLayer(groundBottomImage);
    PlayN.log().debug("graphics().height() * (3 / 4)=" + graphics().height() * (3f / 4f));
    graphics().rootLayer().addAt(groundBottom, 0, graphics().height() * (3f / 4f));

}

The first part is supposed to make a sky on the top half of the screen, and the second part is a background color on the bottom quarter.

I have the following result instead :

enter image description here

And when I comment the first fillRect(), I get the expected result, only for the ground part:

enter image description here

The console shows in both cases:

Updating display mode: 1136 x 640 x 0 @0Hz, fullscreen: false
groundBottomImage.height()=160.0
graphics().height() * (3 / 4)=480.0

Playn 1.8

---- EDIT ----

I reverted to PlayN 1.7, and the same code worked fine.

Was it helpful?

Solution

That's a bug in the 1.8 release, since fixed. I'll make a 1.8.1 release because there are a few pesky bugs that have cropped up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top