问题描述
我对无尽的跑步游戏实际上如何运作感到困惑,从概念上讲,就拥有一个永无止境的画布而言.Sprite Kit 在 NDA 下,所以我打算使用 Cocos2D 作为我的框架.
I am confused as to how endless runner games actually work, conceptually, as far as having a never-ending canvas. Sprite Kit is under NDA, so I am going to use Cocos2D as my framework.
网上有一些针对其他语言和工具的教程,但我只需要基本弄清楚:如果我创建一个特定大小的场景,我如何创建一个永无止境的错觉背景?我只是在场景后面设置动画背景,还是以某种方式动态地增加场景的长度,让我的跑步者真的沿着画布奔跑?
There are some tutorials on the web that are specific to other languages, and tools, but I just need to figure out basically: If I create a scene with a specific size, how do I create the illusion of a never-ending background? Do I just animated backgrounds behind the scene, or do I somehow dynamically add length to the scene, so my runner really is running along the canvas?
我说得有道理吗?我只是无法理解这些游戏使用的实际方法是什么.他们确实觉得跑步者精灵在画布上移动,但也许只是他保持不动而所有元素都在移动?
Do I make sense? I just cannot grasp what the actual method these games use is. They certainly feel like the runner sprite is moving along a canvas, but maybe it's just that he's staying still and all the elements are moving?
推荐答案
让我们想想像jetpack joyride这样的无尽跑步者.
Lets think of endless runner like jetpack joyride.
您可能希望有两个背景节点,每个都比屏幕尺寸大一些(可能是 1.5 或 2 个屏幕宽度).当您加载关卡时,您会加载第一个背景并在第一个结束的坐标处添加第二个背景,以便它们形成长屏幕.然后,当我们在第一个背景离开屏幕时开始沿着这个背景移动角色时,我们可以将它的坐标更改为第二个背景帧结束的坐标.这样,当事情结束时,我们也会这样做.这样,仅使用 2 张长图像,我们就可以模拟基本上无穷无尽的空间.您可以为您的游戏使用更长的序列.当它离开屏幕并呈现它时,您可以将其他节点添加到您的背景中,因此每次看起来都不同.
You might want to have two background nodes, each larger than the screen size by some amount (maybe 1.5 or 2 screen widths). When you load your level, you load first background and add second background at the coordinates where first ends, so that they form long screen. Then when we start moving character along this background when first background leaves screen we can take it, and change its coordinates to those where second background frame ends. This way when this comes to an end, we do the same with it. This way only using 2 long images we can simulate essentially endless space. You can use longer sequences for your game. You can add other nodes to your background when it has left the screen and present it, so it looks different each time.
这篇关于无尽奔跑游戏的一般架构是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!