Reputation: 31
i'm developing a shooting game with bow and arrow.. so how to rotate the BOW..?? i tried with different animation classes but it didnt work...
Upvotes: 3
Views: 5346
Reputation: 8896
A method for rotate the bitmap
public static Bitmap rotateImage(Bitmap src, float degree)
{
// create new matrix
Matrix matrix = new Matrix();
// setup rotation degree
matrix.postRotate(degree);
Bitmap bmp = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
return bmp;
}
Upvotes: 3
Reputation: 1523
You can use the Matrix
class.
Here is some code you can try:
Matrix matrix = new Matrix();
matrix.setRotate(degrees);
Bitmap bmpBowRotated = Bitmap.createBitmap(bmpBow, 0, 0, bmpBow.getWidth(),getHeight(), matrix, false);
Upvotes: 11
Reputation: 41076
This might help you , rotating and scaling a bitmap image using matrix parameter.
http://www.anddev.org/resize_and_rotate_image_-_example-t621.html
Upvotes: 1
Reputation: 1555
Well you can do the rotation manually and go frame-by-frame animation? Simply alter the bitmap that is being drawn each frame. What kinds of animation have you tried so far? I would think this could be done with a RotateAnimation
though?
Upvotes: 1