WEB开发网
开发学院手机开发Android 开发 android 3d 旋转 阅读

android 3d 旋转

 2010-10-12 02:45:00 来源:本站整理   
核心提示:}@Overrideprotected void applyTransformation(float interpolatedTime, Transformation t) {final float FromDegree = mFromDegree;float degrees = FromDegree + (mToDe

}

@Override

protected void applyTransformation(float interpolatedTime, Transformation t) {

final float FromDegree = mFromDegree;

float degrees = FromDegree + (mToDegree - mFromDegree)

* interpolatedTime;

final float centerX = mCenterX;

final float centerY = mCenterY;

final Matrix matrix = t.getMatrix();

if (degrees < = -76.0f) {

degrees = -90.0f;

mCamera.save();

mCamera.rotateY(degrees);

mCamera.getMatrix(matrix);

mCamera.restore();

} else if(degrees >=76.0f){

degrees = 90.0f;

mCamera.save();

mCamera.rotateY(degrees);

mCamera.getMatrix(matrix);

mCamera.restore();

}else{

mCamera.save();

//这里很重要哦。

mCamera.translate(0, 0, centerX);

mCamera.rotateY(degrees);

mCamera.translate(0, 0, -centerX);

mCamera.getMatrix(matrix);

mCamera.restore();

}

matrix.preTranslate(-centerX, -centerY);

matrix.postTranslate(centerX, centerY);

}

}

有了这个类一切都会变得简单的,接着只要在activity中写两个Rotate3d的对象,让两个view,分别做这两个对象的animation就好了。( 原来就这么简单啊!无语)

Java代码

1. //下面两句很关键哦,呵呵,心照不宣。

2. Rotate3d leftAnimation = new Rotate3d(-0, -90, 0, 0, mCenterX, mCenterY);

3. Rotate3d rightAnimation = new Rotate3d(-0+90, -90+90, 0.0f, 0.0f, mCenterX, mCenterY);

4.

5. leftAnimation.setFillAfter(true);

6. leftAnimation.setDuration(1000);

7. rightAnimation.setFillAfter(true);

8. rightAnimation.setDuration(1000);

9.

10. mImageView1.startAnimation(leftAnimation);

11. mImageView2.startAnimation(rightAnimation);

上一页  1 2 3 4 5  下一页

Tags:android 旋转

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接