Use SurfaceView, Canvas Android Games – Drawable or Bitmap

I am using SurfaceView to develop a game. It involves about 15-20 images, some of which have an average resolution of 320X400. I have two questions –

>I use Drawable images and use the drawable(canvas) method to draw images on the screen. I have seen people use Bitmap instead of Drawable to draw images on the screen in some games, and use images as Drawable or Bitmap in Android games. What is the difference. Which is more memory efficient and has good performance when drawing on the canvas?
>Now I am creating the Drawable array and creating Drawable objects of all the images used in the game, and put them in their respective arrays because all the images are needed during the game. I want to know which is better – at the beginning Load all the images in the Drawable or create drawable objects when we need them, and make other undisplayed images repeat this process every time an image is displayed or removed from the screen. Repeating the process of creating and zeroing objects will Have any adverse effects, or is it better than loading all the images at once?

Thank you

>According to my experience, Bitmap is faster than drawable. I’m testing an application that works at 40-45 fps, drawable and bitmap, and I get 57-59 fps. That’s because people use them for games.
>If you have enough memory, I It is recommended that you load all images first. If you start creating and destroying objects, it will often call the garbage collector, which is really slow. If you don’t need high performance, creating and destroying objects will reduce memory usage. If you are trying For making games, this link may be helpful.

Google I/O 2009 – Writing Real-Time Games for Android, especially 22:30 quick java code

I am using SurfaceView to develop a game. It involves about 15-20 images, some of which have an average resolution of 320X400. I have two questions –

> I use Drawable images and use the drawable(canvas) method to draw images on the screen. I have seen in some games that people use Bitmap instead of Drawable to draw images on the screen. What is the difference between using images as Drawable or Bitmap in Android games. Which This is more memory efficient and has good performance when drawing on the canvas?
>Now I am creating the Drawable array and creating Drawable objects of all the images used in the game, and put them in their respective arrays because all the images are needed during the game. I want to know which is better – at the beginning Load all the images in the Drawable or create drawable objects when we need them, and make other undisplayed images repeat this process every time an image is displayed or removed from the screen. Repeating the process of creating and zeroing objects will Have any adverse effects, or is it better than loading all the images at once?

Thank you

>According to my experience, Bitmap is faster than drawable. I am testing an application and the working speed is 40- 45 fps, drawable and bitmap, I get 57-59 fps. That’s because people use them for games.
>If you have enough memory, I suggest you load all the images first. If you start creating and Destroy the object, it will often call the garbage collector, it’s really slow. If you don’t need high performance, creating and destroying objects will reduce memory usage. If you are trying to make a game, this link may help. < p>

Google I/O 2009 – Writing Real-Time Games for Android, especially 22:30 fast java code

Leave a Comment

Your email address will not be published.