如何检查精灵对象是否可见?
我有一个包含以下方法的 Sprite 类数组:x
、y
、width
和 height
。它们根据他的 z
属性进行排序。最后一个在上面。我也有屏幕尺寸。我如何知道特定的精灵是否可见?
I have a Array of Sprite classes with these methods: x
, y
, width
and height
. They are sorted based on his z
property. The last are on top. I have, too, the screen size. How can I know if a specific Sprite are visible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“使其工作”的最简单方法是以反向 Z 顺序渲染。这是最接近的最后一个。
否则你就会遇到寻找遮挡的 N^2 问题。您可以通过构建遮挡树来优化这一点。
另一种选择可能是深度测试缓冲区。
The easiest way to "make it work" is to render in reverse Z order. That is closest last.
Otherwise you have an N^2 problem of finding occlusion. You optimize this by building occlusion trees.
Another option might be depth testing the buffer.