我试图显示背景移动图像并移动2d线图像和球图像,但它没有显示。
这是我的代码:
backGround = BitmapFactory.decodeResource(this.getResources(),
R.drawable.ab);
// decrement the far background
mBGFarMoveX = mBGFarMoveX - 1;
// decrement the near background
mBGNearMoveX = mBGNearMoveX - 4;
// calculate the wrap factor for matching image draw
int newFarX = backGround.getWidth() - (-mBGFarMoveX);
// if we have scrolled all the way, reset to start
if (newFarX <= 0) {
mBGFarMoveX = 0;
// only need one draw
c.drawBitmap(backGround, mBGFarMoveX, 0, null);
} else {
// need to draw original and wrap
c.drawBitmap(backGround, mBGFarMoveX, 0, null);
c.drawBitmap(backGround, newFarX, 0, null);
}
除了显示背景图片外,一切都很顺利。 背景显示为黑色,我的程序运行得很慢。