开发者

Android App How to draw multiple instances of a image

I've done some messing around with Android apps, but so far only made apps with the built in views, like buttons textfields, etc. I'm now trying to convert a game I made in java for the computer to an Android app, as that was my original intention, I just didn't have a droid at the time and found the emulator too frustratingly slow to do any real testing.

So far everything's gone well converting it and figuring out the app life cycle, but I'm at a loss when it comes to graphics. I've read through pages of the android dev library, few tutorials, and questions here on stackoverflow. I thought I was understanding it but lately it seems like the more I read the more confused I get.

I have images I've put into the drawable folders, but now I need to know how to draw multiple instances of them to the screen. I don't need them to be clickable, just be able to be resized, rotated, and moved around the screen. From what I understand this should be done with tween animations, but I'm having trouble finding any information on using tween.

My original plan was to create a class that extended ImageView, but I didn't know where to go from there. So I guess my question is how do I load an image from my drawables folder, resize it to fit the screen dimensions, and then rotate it around so I can create an array of rotated versions of the image to use.

Then from there how do I create multiple Views or whatever else I should use to be able to display multiple instances of the image, in various rotations.

Another problem I ran into was that the android class overview for View shows that it has methods setX, setY, setTranslationX, etc. to move the view around the layout it's on, but eclipse doesn't show those methods for my ImageViews or Views.

开发者_运维问答

Sorry if this is too much for one question, I'll trim it down to a more specific question if I need to.

Thanks in advance for your time.


Take a look at the SurfaceView class. It is usually used for game development since it gives you the opportunity to draw objects on its Canvas. It's much easier to use when you're developing a game with lots of objects and movement. Hope this helps.


SetX / setTranslationX were introduced with SDK Version 11, hence if your project uses a lower version you can't use the methods!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜