> I run my app on emulator, and currently have > not tested it on real device.
The emulator is not, in any way, going to run the same speed as a real device. Run it on a real device and see what FPS you get. Or if you want, publish an APK and someone here will run it I'm sure (I'll do it =P) - Dan On Wed, Jan 20, 2010 at 1:44 AM, Andre <andranik.abra...@gmail.com> wrote: > Hi, > > Yesterday, I've changed my code, to work with the matrix more > effectively... > > My GameEntity class now looks like this: > > ----------GAME ENTITY---------- > > public class GameEntity { > public Bitmap mBitmap; > private Rect mBounds; > private Matrix mMatrix; > public int mWidth; > public int mHeight; > public boolean mAlive; > public float mX, mY; > public float mVelocityX, mVelocityY; > public float mMoveAngle, mFaceAngle; > public float mRotationVelocity; > > public GameEntity(Bitmap bitmap) { > mBitmap = bitmap; > mBounds = new Rect(); > mMatrix = new Matrix(); > mWidth = bitmap.getWidth(); > mHeight = bitmap.getHeight(); > mAlive = false; > mX = 0.0f; > mY = 0.0f; > mVelocityX = 0.0f; > mVelocityY = 0.0f; > mMoveAngle = 0.0f; > mFaceAngle = 0.0f; > mRotationVelocity = 0.0f; > } > > public void draw(Canvas canvas, float angle) { > Matrix m = mMatrix; > m.reset(); > m.postTranslate(mX - mWidth / 2, mY - mHeight / 2); > m.postRotate(angle, mX, mY); > canvas.drawBitmap(mBitmap, m, null); > } > > public Rect getBounds() { > mBounds.left = (int)(mX - mWidth / 2); > mBounds.top = (int)(mY - mHeight / 2); > mBounds.right = (int)(mX + mWidth / 2); > mBounds.bottom = (int)(mY + mHeight / 2); > return mBounds; > } > } > > And "draw" methods in GameView class: > > ----------GAME VIEW---------- > > private void drawSpaceship(Canvas canvas) { > mSpaceship.draw(canvas, mSpaceship.mFaceAngle); > } > > private void drawAsteroids(Canvas canvas) { > GameEntity[] asteroids = mAsteroids; > GameEntity asteroid; > for(int i = 0; i < MAX_ASTEROIDS; i++) { > asteroid = asteroids[i]; > if(asteroid.mAlive) { > asteroid.draw(canvas, asteroid.mMoveAngle); > } > } > } > > private void drawBullets(Canvas canvas) { > GameEntity[] bullets = mBullets; > GameEntity bullet; > for(int i = 0; i < MAX_BULLETS; i++) { > bullet = bullets[i]; > if(bullet.mAlive) { > bullet.draw(canvas, bullet.mMoveAngle + 90); > } > } > } > > This gives me an extra 4-5 FPS, and now I have ~25 FPS. > It worth to mention, that I run my app on emulator, and currently have > not tested it on real device. > > I decide to go little further with testing and commented out > m.postTranslate() method call, and got +4 FPS, after that I commented > out m.postRotate(), and got +12-15 FPS, it seems that rotation (with > pivot points) is very costly... > > Best Regards, Andre > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en >
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en