开发者

Extending the Bitmap Class in Android?

Is there a way to extend the Bitmap class in Android? I have a feeling 开发者_如何学Cyou can't, but I would like to create a class for a bitmap which represents a falling object ( there will be an indeterminate number of this objects falling from the top of the screen, and each will have to perform some sort of collision detection). Can I extend/implement the bitmap class to create this custom class that I want?


You can't extend Bitmap, because it is declared final. The best you can do is create a class that wraps a Bitmap.


A Bitmap doesn't even know where it should be placed on the screen.

Even before you get into animation, it seems like you need to represent your scene using a few "SceneObject" objects or some other model that can represent objects with coordinates in your scene. Each of these objects would have as an instance variable a Bitmap.

Once that step is complete, animating your objects may just be extending your "SceneObject" class with additional functionality.

Your rendering function would interpret your scene and layout bitmaps according to the information in your models.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜