2014-02-12 52 views
0

我有這樣的代碼非常簡單:fillRect似乎沒有填滿整個Rectange

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)); 

} 

第一部分是應該讓屏幕的上半部分天空,而第二部分是在底部季度的背景顏色。

我有以下的結果,而不是:

enter image description here

當我評論第一fillRect(),我得到預期的結果,只對地上部分:

enter image description here

的在兩種情況下的控制檯顯示:

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

Playn 1.8

---- ----編輯

我收歸PlayN 1.7,同樣的代碼工作的罰款。

回答

1

這是1.8版本中的一個錯誤,因爲已修復。我將發佈1.8.1版本,因爲有幾個棘手的bug已經出現。

+0

謝謝你的回答。在旁註中,是否可以在iOS版本上將顯示寬度更改爲1136 px?與iOS上的其他版本不同,我無法更改寬度/高度。 –