Bitmap rotation jitter around pivot
Posted
by
Manderin87
on Game Development
See other posts from Game Development
or by Manderin87
Published on 2012-11-15T19:09:10Z
Indexed on
2012/11/16
5:14 UTC
Read the original article
Hit count: 208
I am working on a asteriods clone and I have the ship graphic loaded as a 96x96 bitmap. When the player rotates the ship I rotate the bitmap by degree (float).
rotation function:
if(m_Matrix == null) {
m_Matrix = new Matrix();
} else {
m_Matrix.reset();
}
m_Matrix.setRotate(degree, m_BaseImage.getWidth() / 2,
m_BaseImage.getHeight() / 2);
m_RotatedImage = Bitmap.createBitmap(m_BaseImage, 0, 0, m_BaseImage.getWidth(),
m_BaseImage.getHeight(),
m_Matrix, true);
draw function:
m_Paint.setAntiAlias(true);
m_Paint.setFilterBitmap(true);
m_Paint.setDither(true);
canvas.drawBitmap(m_RotatedImage, (int) posX - m_RotatedImage.getWidth() / 2,
(int) posY - m_RotatedImage.getHeight() / 2, m_Paint);
When the bitmap is drawn, the bitmap jitters slightly around the pivot.
Can anyone fix or tell me why the bitmap is jittering around the pivot? It needs to be smooth.
© Game Development or respective owner