显示图形的最佳方法
所以我正在为 Android 制作一个简单的游戏,并且我正在尝试找出应该使用哪种渲染方法。我很新,所以更简单=更好。我想做的事情非常简单:绘制 2.5D(倾斜图像)盒子来形成一个看起来像洞穴的东西,就像你正在寻找一个无限的盒子,角色会在其中跑下来并跳来跳去。然而,洞穴由数十个盒子组成,这些盒子在生成时随机分配和打开/关闭。取自 http://developer.android.com/guide/topics/graphics /2d-graphics.html 哪个选项最适合我的情况?角色将根据加速度计倾斜进行移动,并且可以自由移动,而盒子永远不会改变视角。
So I'm making a simple game for Android and I'm trying to figure out which method of rendering I should use. I'm pretty new so simpler = better. The thing I'm trying to do is pretty simple: draw 2.5D (skew images) boxes to form a cave looking thing, like you're looking into an infinite box that a character will run down and jump around in. The cave however is made up of dozens of boxes that are assigned and on/off randomly when spawned. Drawing from http://developer.android.com/guide/topics/graphics/2d-graphics.html which option would be ideal for my situation? The character will move based on the accelerometer tilt and has free movement while the box never changes perspective.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您最有可能想要使用表面视图,因为它可以以最简单的方式处理自定义动画。
理想的情况是学习 OpenGL 和 3D 变换。没有真正的2.5d。您可能谈论的是 3D 正交投影。有时这是使用 2d 精灵完成的,有时是使用 3d 对象完成的。
为了捕获传感器信息,您可以使用 Android API 中的 SensorManager。
You are going to want to use a surfaceview most likely, since it can handle custom animation in the easiest manner.
Ideal would be to learn OpenGL and 3D transforms. There is no real thing as 2.5d. What you are probably talking about is a 3D Orthographic Projection. Sometimes this is done with 2d sprites, sometimes it's done with 3d objects.
For capturing the Sensor Information you would use SensorManager in the Android API.
嘿,这完全取决于您需要绘制多少个单独的位图以及您希望的帧速率。绘制到画布是通过 CPU 完成的,因此它比使用硬件加速的 Opengl 慢。画布实际上可以完成大约 20-40 个 20x20px 位图的出色工作。 (这是根据过去的经验得出的,非常粗糙)。
如果可以的话,我会坚持使用画布,因为它很简单。它将帮助您更好地理解什么是游戏循环以及如何设计游戏的内部结构。
祝你好运
Hey this is entirely based on how many separate bitmaps you need to draw and what you would like your frame rate to be. Drawing to the canvas is done via the cpu so it is slower than using Opengl which is hardware accelerated. The canvas actually does an amazing job up to roughly 20-40 20x20px bitmaps. (this is from past experience and is extremely rough).
I would just stick to using the canvas if you can since its simple. It will help you gain a better understanding of what a game loop is and how to design the internals of your game.
Good Luck
该页面上的“选项”:使用视图布局或画布实际上是选项。 Android 中的所有绘图(除了 OpenGL 和其他低级 3D 渲染)都是在
Canvas
上完成的。这里的选项更多的是关于如何指定在画布上绘制的内容。第一个选项允许您使用布局 xml 指定在画布上绘制的内容。第二个选项是在 View 的 onDraw() 方法期间直接在 Canvas 上绘图。
对于具有任何类型的逼真运动和动画的游戏,您需要在 onDraw() 事件期间直接在画布上绘图。
您也许可以为菜单屏幕进行一些静态(布局 xml)绘图。
The "options" on that page: using a view layout or a canvas are really options at all. All drawing in android (aside from OpenGL and other lowlevel 3D rendering) is done on a
Canvas
.The options here were more about how to specify what is drawn on the Canvas. The first option allows you to specify what is drawn on the canvas using the layout xml. The second option is about drawing directly on the Canvas during a View's onDraw() method.
For a game with any kind of realistic movement and animation, you'll want to draw directly on the Canvas during the onDraw() event.
You might be able to do some static (layout xml) drawing for menu screens.