I have been using a shapeDrawable object for my android games player but now that i want to add some graphics in I have to use something different I was thinking of a BitmapDrawable but as I am new to this I have no idea how to initialize these sorts of classes, or how to get the image from the game resources could anyone put me on the right track or point me to some helpful tutorials.


1 Answer 1


This is how you create a bitmap from a resource id :

bm = BitmapFactory.decodeResource(getResources(), R.drawable.image);

To create a BitmapDrawable from a bitmap :

bmDrawable=new BitmapDrawable(getRsources(), bm);

Be aware that, depending on the kind of game you are making, you might want to use the NDK and an opengl game engine like Cocos2d-x for example ( http://www.cocos2d-x.org/ ).

The Android SDK has not been designed for game, or maybe for simple games like crosswords, or sudoku, with not too much graphics fx. The powerful Android layout system on is designed to build a GUI for different screen sizes, but it's requiring too much CPU for most of the game.

I remember starting making a game for iOS 3 years ago with the UIKit library (equivalent of Android SDK/Layouts on iOS). The game was working fine but I was stuck with low performances, unresponsive touch screen, and it was impossible to add more on the rendering pipeline (like particles fx). I rewrote completely the game with Cocos2d, and that was so much better/smooth.

  • \$\begingroup\$ Thanks for the tip, i started by using opengl but it was really complicated and i had no idea how to use it so i thought canvas might be a better way to go \$\endgroup\$
    – Dan
    Jul 21, 2012 at 23:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .