Camera
클래스를 소개해 드리겠습니다. 아니, 하드웨어 카메라가 아닙니다.
Camera | Android Developers
이
은
graphics
Camera
입니다. 표준 배율, 회전 및 애니메이션은 모두 x-y 평면에서만 작동하지만
Camera
은 이미지에
perspective 인을 제공하는 z 축을 도입하고 사용자가 2 대신 3 차원으로 변형 할 수 있도록합니다.
rotateY()
메서드에 가장 관심이있을 것입니다. 이것은 뒤집어 진 카드 나 타일의 애니메이션을 만드는 데 도움이되는 방법입니다.
- : 당신이, 당신은 여러 가지 방법으로 이것을 사용할 수 있습니다 변환 할 수있는 매트릭스가 이제
private Matrix mMatrix;
private Camera mCamera;
// val is animation value between -1.0 and 1.0
private void updateImageMatrix(float val) {
// turn the animation value into an angle from
// 0 to -90, then +90 to 0 degrees
float degrees = 90.0F * (Math.signum(val) - val);
mCamera.save(); // save initial state
mCamera.rotateY(degrees); // this does the flip
mCamera.getMatrix(mMatrix); // write the transform into the matrix
mCamera.restore(); // now we can reuse the Camera without re-constructing
float centerX = imageWidth/2.0F;
float centerY = imageHeight/2.0F;
// Y-axis is at the left edge, so to get rotation
// around the center, we have to move the image over
// first, then move it back after we rotate
mRotateMatrix.preTranslate(- centerX, - centerY);
mRotateMatrix.postTranslate(centerX, centerY);
// this could probably be eliminated by initializing mCamera with
// mCamera.setLocation(centerX, centerY, mCamera.getLocationZ())
// the image probably isn't exactly the same size as the
// view, so we have to handle scaling the image to the view
mRotateMatrix.preScale(mScaleFactor, mScaleFactor);
}
: 여기
내가 타일 플립의 Camera
클래스를 사용하는 방법
이 행렬을 이미지 행렬로 설정하여 ImageView
을 가질 수 있습니다.
사용자 정의 View
을 가질 수 있습니다. t는 onDraw
및 호출을 무시 canvas.drawBitmap(mBitmap, mMatrix, null)
당신은 applyTransformation(float interpolatedTime, Transformation t)
을 무시하고 반환하는 사용자 정의 Animation
클래스를 가질 수 플립, 당신은 첫 번째 애니메이션을 적용 할 것,
또한 매트릭스를 기반으로 Transformation
업데이트 이미지를 0에서 -90도까지 확대 한 다음 해당 이미지를 숨기고 나머지는 90도에서 0도까지 애니메이트하면서 두 번째 이미지를 표시합니다.
마지막으로 한 가지. 3x3 격자가 있습니다. 현실적인 3 차원 뒤집기 효과를 얻으려면 mCamera.setLocation()
을 사용해 타일에 따라 x 및 y 값을 다르게하여 맨 아래의 타일이 아래에서부터 플립을 보는 것처럼 보일 것입니다. 오버 헤드 등에서 플립을보고 있습니다.