I m working on a simple game where a ball tumbles on a slope and has to avoid the obstacles by jumping. The problem comes when I am trying to rotate the ball object using the Matrix. I am using the following code:-
private void rotateMe() {
if(jump==0){
Matrix mtx=new Matrix();
mtx.postRotate(deg);
Bitmap rotatedBMP=Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), mtx, false);
deg=deg+1; //deg=0 in beginning
bm=rotatedBMP;
}
}
This method is written in the class of ball, which is internally called by another method move(). The bitmap bm is not rotating as I wanted. It’s just falling out of the screen, which seems like the size of bitmap has increased. And I’ve to force close it after few seconds.
I’ve seen other rotate bitmap questions, but they are not working for me too.
Thanks in advance.
Anyways found the answer by myself. The code I am using now is as follows (for those who are having same problem)
The code is running fine now.
Thanks anyways.