请帮助旋转 2 面图像(如硬币) - 换面动画,当第一个图像可见时,第二个不可见。当我旋转图像时,直到旋转角度小于 90 度,我显示第一张图像,否则显示第二张图像。
现在,它在 Y 轴 (A) 上旋转,但我需要在轴上旋转图像 - 旋转图像的中心 (B)。
转换:
long aniAngle = (System.currentTimeMillis() - animationStart)*180/ANIMATION_TIME;
aniCamera.save();
if(aniAngle <= 90)
{
aniCamera.rotateY(aniAngle); // angle of current rotation
aniCamera.getMatrix(aniMatrix);
aniCamera.restore();
int centerX = x + image.getWidth()/2;
int centerY = y + iamge.getHeight()/2;
aniMatrix.preTranslate(-centerX, -centerY);
aniMatrix.postTranslate(centerX, centerY);
canvas.save();
canvas.concat(aniMatrix);
Bitmap image = angle < 90 ? image1 : image2;
if(image == image2)
angle = 180 - angle; // second image goes from rotated state to normal - degrees of rotation should decrease during animation
c.translate(x + image.getWidth()/2, y + cover.getHeight()/2); // 图像左上角坐标 (x,y)
c.rotate(angle); // angle of rotation non animated image
c.drawBitmap(image, -image.getWidth()/2, -image.getHeight()/2, null);