我正在尝试使动画围绕y轴旋转+缩放+同时旋转。
旋转动画基于this。目前我在动画集中拥有所有动画,但它很慢。所以我想我可以在旋转动画中组合所有三个动画,因为我已经有了一个applyTransformation。所以我检查了Android源码的ScaleAnimation和TranslateAnimation,看起来一切都很简单。但它不起作用。
现在问题是:甚至可能吗?如果是的话:我做错了什么?
编辑:我越来越近了!现在翻译和轮换工作。只缺少缩放。这是我的代码:
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float degrees = fromDegrees + ((toDegrees - fromDegrees) * interpolatedTime);
float sx = 1.0f;
float sy = 1.0f;
if (scaleFromX != 1.0f || scaleToX != 1.0f) {
sx = scaleFromX + ((scaleToX - scaleFromX) * interpolatedTime);
}
if (scaleFromY != 1.0f || scaleToY != 1.0f) {
sy = scaleFromY + ((scaleToY - scaleFromY) * interpolatedTime);
}
float dx = fromDeltaX;
float dy = fromDeltaY;
if (fromDeltaX != toDeltaX) {
dx = fromDeltaX + ((toDeltaX - fromDeltaX) * interpolatedTime);
}
if (fromDeltaY != toDeltaY) {
dy = fromDeltaY + ((toDeltaY - fromDeltaY) * interpolatedTime);
}
final Matrix matrix = t.getMatrix();
matrix.setTranslate(dx, dy);
matrix.setScale(sx, sy, pivotX, pivotY);
camera.save();
if (reverse) {
camera.translate(0.0f, 0.0f, interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, 1.0f - interpolatedTime);
}
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX + dx, centerY + dy);
}