我希望能够旋转也是动画的移动精灵(atm连续有3张图像)。我该怎么做?
当前精灵在屏幕上移动并旋转。
到目前为止,我已经得到了这段代码:(但它看起来搞砸了)
this._rect = new Rect(0,0, this._spriteWidth, this._spriteHeight);
//this._rect.left = 1 * this._spriteWidth;
//this._rect.right = this._rect.left + this._spriteWidth;
//What the bitmap will be fitted into.
Rect dest = new Rect(current_Position.x, current_Position.y, current_Position.x + this._spriteWidth, current_Position.y + this._spriteHeight);
mMatrix.reset();
mMatrix.postRotate(Degrees, _spriteWidth / 3, _spriteHeight / 2);
mMatrix.postTranslate(current_Position.x, current_Position.y);
this._modified_bitmap = Bitmap.createBitmap(_bitmap, 0, 0, _bitmap.getWidth(), _bitmap.getHeight(), mMatrix, false);
canvas.drawBitmap(_modified_bitmap, _rect, dest, null);
有人可以帮忙谢谢吗?
---已解决(虽然如果有人知道更有效的方式,请告诉我)---
mMatrix.reset();
mMatrix.postRotate(Degrees, _spriteWidth / 3, _spriteHeight / 2);
mMatrix.postTranslate(current_Position.x, current_Position.y);
this._modified_bitmap = Bitmap.createBitmap(_bitmap, 0, 0, _spriteWidth, _spriteHeight);
canvas.drawBitmap(_modified_bitmap, mMatrix, null);
答案 0 :(得分:0)
---已解决(虽然如果有人知道更有效的方式,请告诉我)---
mMatrix.reset();
mMatrix.postRotate(Degrees, _spriteWidth / 3, _spriteHeight / 2);
mMatrix.postTranslate(current_Position.x, current_Position.y);
this._modified_bitmap = Bitmap.createBitmap(_bitmap, 0, 0, _spriteWidth, _spriteHeight);
canvas.drawBitmap(_modified_bitmap, mMatrix, null);