5
我有一個功能,它需要一個無縫的位圖並使用世界座標在屏幕上以任意方向滾動。有4個畫圖(播放區域小於完整的位圖大小。因此,最多可以看到4個位圖副本,只是繪製不同的區域以保持無縫效果)。我想知道的是,我是否應該對矩形邊界應用修改,以便它只將它應該在屏幕上顯示的部分抹掉?或者我應該讓Android處理? 如果我自己做,我該如何處理?就數學而言,世界的座標和平移確實讓我感到困惑。 :/我應該依靠Android來放棄屏幕外抽獎嗎?
這是代碼。
public void draw(Canvas canvas){
oCoords.x=(int) fX;
oCoords.y=(int) fY;
oTopLeft = gridContainingPoint(oCoords);
oTopRight.x = gridContainingPoint(oCoords).x + iWidth;
oTopRight.y = gridContainingPoint(oCoords).y;
oBottomLeft.x = gridContainingPoint(oCoords).x;
oBottomLeft.y = gridContainingPoint(oCoords).y + iHeight;
oBottomRight.x = gridContainingPoint(oCoords).x + iWidth;
oBottomRight.y = gridContainingPoint(oCoords).y + iHeight;
canvas.save();
canvas.translate(-fX, -fY);
oCloud.setBounds(oTopLeft.x, oTopLeft.y, oTopLeft.x + this.iImageWidth, oTopLeft.y + this.iImageHeight);
oCloud.draw(canvas);
oCloud.setBounds(oTopLeft.x + this.iImageWidth, oTopLeft.y, oTopLeft.x + (this.iImageWidth * 2), oTopLeft.y + this.iImageHeight);
oCloud.draw(canvas);
oCloud.setBounds(oTopLeft.x, oTopLeft.y + this.iImageHeight, oTopLeft.x + this.iImageWidth, oTopLeft.y + (this.iImageHeight * 2));
oCloud.draw(canvas);
oCloud.setBounds(oTopLeft.x + this.iImageWidth, oTopLeft.y + this.iImageHeight, oTopLeft.x + (this.iImageWidth * 2),oTopLeft.y + (this.iImageHeight * 2));
oCloud.draw(canvas);
canvas.restore();
}