我使用过这种方法,但根据我的要求不能正常工作,请建议我
public void applyTransformation(float interpolatedTime, Transformation t) {
float dx = 0, dy = 0;
if (mFromXValue != mToXValue) {
dx = (float) ((1.0 - interpolatedTime) * (1.0 - interpolatedTime)
* mFromXValue + 2.0 * interpolatedTime
* (1.0 - interpolatedTime) * mBezierXDelta + interpolatedTime
* interpolatedTime * mToXValue);
}
if (mFromYValue != mToYValue) {
dy = (float) ((1.0 - interpolatedTime) * (1.0 - interpolatedTime)
* mFromYValue + 2.0 * interpolatedTime
* (1.0 - interpolatedTime) * mBezierYDelta + interpolatedTime
* interpolatedTime * mToYValue);
}
t.getMatrix().setTranslate(dx, dy);
}
答案 0 :(得分:0)
在sprite类中使用这个方法它会帮助你......
public void paintFromCenter(float angle, Canvas c) {
Bitmap b = sprite;
Matrix matrix = new Matrix();
matrix.postRotate(angle, b.getWidth() / 2, b.getHeight());
matrix.postTranslate(getX(), getY());
Bitmap bmp2 = Bitmap.createBitmap(b, 0, 0, frameWidth, frameHeight,
matrix, true);
c.drawBitmap(b, matrix, null);
}