I want to be able to rotate a moving sprite which is also animated (atm has 3 images in a row). How would I go about this?
The current sprite moves around the screen and rotates.
So far I’ve got this code: (But it looks messed up)
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);
Can anyone help thanks?
— Resolved (Although if anyone knows a more efficient way please let me know) —
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);
— Resolved (Although if anyone knows a more efficient way please let me know) —