我正试图建造一只简单的“飞鸟”#34;游戏,我需要让鸟的图像倾斜,向上指向上,反之亦然。但是,当旋转我的图像时,它会在掉落一点点或点击屏幕后部分或完全从屏幕上消失。有人可以告诉我如何解决这个问题吗?
matrix = new Matrix();
if(angle > minAngle && angle < maxAngle && !boosting) {
angle+=avel;
matrix.postRotate(angle);
}
if(boosting) {
angle = -20;
matrix.postRotate(angle);
speed = -30;
}
rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, 50, 50, matrix, true);
bitmap = rotatedBitmap;
//Now the player object gets this rotated image and adds it to the Canvas
答案 0 :(得分:0)
private Bitmap rotation(Bitmap myBitmap) {
int rotate = 90; // degree of rotation;
Matrix matrix = new Matrix();
matrix.postRotate(rotate);
if (myBitmap != null) {
return myBitmap = Bitmap.createBitmap(myBitmap, 0, 0, myBitmap.getWidth(),
myBitmap.getHeight(), matrix, true);
}
return myBitmap;
}