dev.android.com 的 JetBoy 示例的解释?
我用java开发了许多桌面或网络应用程序,但从未开发过Android应用程序。
我练习的很少,这很奇怪,因为我习惯了 SWING。由于它使用 .xml 文件作为应用程序,我想知道您在游戏中是否也需要它?
例如,http://developer.android.com/resources 有一个很好的例子/samples/JetBoy/index.html。我希望有人能为我解释两件事。
- 图像是如何绘制到屏幕上的?
- 您如何监听用户输入? (例如,点击、绘图、滑动等...)
我在桌面上制作了游戏,因此您不必深入了解,但我发现很难理解代码。 (我本来应该为android做一些特别的事情。)
(另一种说法:)
我想基本上我要问的是如何绘制一个图像,该图像将依次监听点击等而不添加按钮?或者我需要添加一个隐形按钮?那么,如果我确实必须添加一个按钮,我将如何监听滑动和绘图?
我还看到了一些方法,如 doDraw(),但没有看到它们将图像放在哪里,以便它出现在 Android 设备上。
I have developed many applications for desktop or web in java, but never for android.
What little I have practiced with was weird because I am used to SWING. Since it uses .xml files for applications I was wondering if you needed this also in games?
For example there is a a good example at http://developer.android.com/resources/samples/JetBoy/index.html. I was hoping someone could explain two things for me.
- How is the image drawn to the screen?
- How do you listen for user input? (Eg. Clicks, drawing, swiping, ect...)
I have made games on the desktop so you don't have to get in depth, but I found it hard to understand the code. (What I was suppose to do special for android.)
(Another way to put it:)
I guess basically what I am asking is how to I draw an image that will in turn listen to clicks and such without adding a button? Or do I need to add an invisible button? Then if I did have to add a button how would I listen for swiping and drawing?
Also I saw some methods like doDraw(), but did not see where they were putting the image so it would appear on the android device.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为这会告诉你你需要知道的一切,在一个由 31 个部分组成的综合系列中,详细介绍了适用于 Android 的 Light Racer 3d 的创建。
I think this will tell you everything you need to know, in a comprehensive, 31 part series detailing the creation of Light Racer 3d for Android.
如果您不打算使用任何游戏引擎,
基本上你扩展了
android.view.SurfaceHolder
然后
覆盖
这些方法,public boolean onTouchEvent(MotionEvent 事件)
protected void onDraw(Canvas canvas)
遍历
这些文章。它从头开始教您所需的一切
If you are not going to use any Game Engine ,
basically you extend
android.view.SurfaceHolder
and then
overide
these methods,public boolean onTouchEvent(MotionEvent event)
protected void onDraw(Canvas canvas)
go through
these articles.It teaches everything you need from the scratch
JetBoy 对于初学者来说相当复杂,请查看这些简单的示例,它们基于与 JetBoy 相同的原理:如何在画布内使用动画框架?
一切都是通过在画布上绘制位图来完成的视图的画布和一个检测屏幕何时何地被触摸的事件。
JetBoy is rather complicated for a beginner, check these simple examples which are based on the same principles as JetBoy: How can I use the animation framework inside the canvas?
Everything is done by drawing bitmaps on the view's canvas and an event which detects when and where the sreen was touched.