Android应用程序如何绘制图像的多个实例

发布于 2024-12-06 02:37:50 字数 757 浏览 0 评论 0原文

我已经对 Android 应用程序做了一些修改,但到目前为止只制作了具有内置视图的应用程序,例如按钮文本字段等。我现在正在尝试将我用 java 为计算机制作的游戏转换为 Android 应用程序,因为这是我的初衷,我当时没有机器人,并且发现模拟器速度太慢,无法进行任何真正的测试。

到目前为止,转换它并弄清楚应用程序生命周期的一切都很顺利,但当涉及到图形时我却不知所措。我已经阅读了 android 开发库的页面、一些教程以及 stackoverflow 上的问题。我以为我理解了它,但最近似乎我读得越多,我就越困惑。

我已将图像放入可绘制文件夹中,但现在我需要知道如何将它们的多个实例绘制到屏幕上。我不需要它们可点击,只需能够调整大小、旋转和在屏幕上移动即可。据我了解,这应该通过补间动画来完成,但我无法找到有关使用补间的任何信息。

我最初的计划是创建一个扩展 ImageView 的类,但我不知道从哪里开始。所以我想我的问题是如何从我的可绘制文件夹中加载图像,调整其大小以适合屏幕尺寸,然后旋转它,以便我可以创建要使用的图像的旋转版本的数组。

然后,从那里我如何创建多个视图或我应该使用的其他任何东西,以便能够以各种旋转方式显示图像的多个实例。

我遇到的另一个问题是 View 的 android 类概述显示它有 setX、setY、setTranslationX 等方法来在其所在的布局上移动视图,但 eclipse 没有为我的 ImageViews 或 Views 显示这些方法。

抱歉,如果这对于一个问题来说太多了,如果需要,我会将其缩减为更具体的问题。

预先感谢您的宝贵时间。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

︶葆Ⅱㄣ 2024-12-13 02:37:50

看一下 SurfaceView 类。它通常用于游戏开发,因为它使您有机会在其 Canvas 上绘制对象。当您开发具有大量对象和运动的游戏时,它会更容易使用。希望这有帮助。

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.

风尘浪孓 2024-12-13 02:37:50

SetX / setTranslationX 是在 SDK 版本 11 中引入的,因此如果您的项目使用较低版本,则无法使用这些方法!

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文