両面画像 (コインのようなもの) を回転させるのを手伝ってください - 最初の画像が表示されている場合、2 番目の画像が表示されていないときの側面の入れ替えのアニメーション。画像を回転すると、回転角度が 90 度未満になるまで最初の画像が表示され、それ以外の場合は 2 番目の画像が表示されます。
現在、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);