寻找屏幕边缘android
这听起来可能非常明显,但我如何找到沿屏幕边缘的点,以便知道移动的物体是否撞击了屏幕边缘。
谢谢
This may sound really obvious but how can I find the points along the edge of the screen in order to know if a moving object has hit the edge of the screen.
Thankyou
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有正交投影,您可以通过了解传递给
glOrtho()
函数的值轻松了解边缘在哪里。例如,考虑这一行:
在这里您可以决定单个浮点数对程序的影响有多大。您可以在此处找到更多信息。
但是,在这种情况下,您的左边缘为 0.0,下边缘为 0.0。您的上边缘由高度定义,右边缘由宽度定义。
通过这种方式,您不必依赖特定的屏幕尺寸,因为您的世界将始终与您定义的一样大。例如,您不需要通过 width 和 height 参数定义正交宽度和高度,而是使用一些数据告诉您的应用程序您的世界应该有多大。
Given you have orthographic projection, you can easily know where your edges are by knowing the values you've passed into the
glOrtho()
function.For example, consider this line:
Here you can decide how big influence a single float will have in your program. You can find more information about this here.
However, in this scenario your left edge is 0.0 and your bottom edge is 0.0. Your top edge is defined by height and your right edge is defined by width.
In this way you don't have to rely on a specific screen size since your world will always be as big as you define. For example, you don't need to define the orthographical width and height by the width and height parameters, but instead use some data telling your application how big your world should be.
只需这样做:
Just do this: