请帮助旋转双面图像(如硬币) - 双面交换动画,当第一张图像可见时,第二张图像不可见。当我旋转图像时,直到旋转角度小于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);