无限地图/滚动问题

发布于 2024-09-17 19:41:25 字数 411 浏览 5 评论 0原文

我正在使用 iPhone 版的 cocos2d 创建无限滚动的水平平铺地图。为了实现这一目标,我生成了一个“段”库,它们基本上是水平的级别块,我随机选择这些级别并将其附加到该特定级别图块地图的末尾。当图块滚动离开屏幕左侧时,它们将从图层中移除并释放。这一切都很好。

我的问题围绕我选择的滚动方法的合法性。遵循本文的指导,我一直通过定期更新图层位置来滚动地图(从 x 轴中减去以将图层向左移动)。虽然这有效,但我担心图层的定位可能存在一些有限的限制。经过一定时间后(当层 x 轴位置相当大时)我是否会遇到问题?

对我的方法有任何想法将不胜感激。

I'm using cocos2d for the iPhone to create an infinitely scrolling horizontal tile map. To achieve this, I've generated a library of 'segments', which are basically horizontal chunks of levels that I randomly choose from and append to the end of that particular levels tile map. When tiles scroll off of the left of the screen they are removed from the layer and released. This all works fine.

My question revolves around the legitimacy of the scrolling method I've chosen. Following guidance from this article, I've been scrolling my map by updating the layers position at regular intervals (subtracting from the x axis to move the layer to the left). And while this works, I'm concerned that there's probably some finite limit to the positioning of a layer. Am I going to run into issues after a certain amount of time has passed (when the layers x-axis position is considerably large?)

Any thoughts on my approach would be appreciated.

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

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

发布评论

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

评论(1

谁对谁错谁最难过 2024-09-24 19:41:25

这是一个好问题。我要做的就是运行一些测试来确定图层的定位距离。我放置了一个精灵并将相机聚焦到 ccp(1000000000000000, 1000000000000000),没有任何问题。

您真的认为这会成为实际游戏中的问题吗?看起来需要很长时间的比赛才能达到这样的位置。

This is a good question. What I would do is run some tests on how far you can position the layer. I placed a sprite and focused the camera to ccp(1000000000000000, 1000000000000000) with no issues.

Do you really think this would be an issue in real gameplay? Seems like it would take a very long game to reach a position like that.

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