Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
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 –  Dan Jul 21 '12 at 23:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.