如何渲染2D横向卷轴游戏 [英] How to render a 2d side-scroller game
问题描述
我真的不理解的方式,我假设呈现一个横向卷轴?我怎么知道该怎么渲染的时候,我的性格动?我应该使用的字符是什么样的为定位的? 我希望我的问题是清楚的。
I do not really understand the way I'm suppose to render a side-scroller? How do I know what to render when my character move? What kind of positionning should I use for the characters? I hope my question is clear
推荐答案
最简单的方法我发现做到这一点是有一个characterX和characterY变量[整数或浮点数,任何你想要的]然后有一个cameraX和cameraY变量。场景中的每个对象被绘制在theObjectX-cameraX,theObjectY-cameraY ...
The easiest way i've found to do it is have a characterX and characterY variable [integer or float, whatever you want] Then have a cameraX and cameraY variable. Every object in the scene is drawn at theObjectX-cameraX, theObjectY-cameraY...
CameraX / CameraY是由一个类似的到中间点式补间让他们最终会达到PlayerX的/ playery [CX =(CX * 99 +过氧化物酶)/ 100]
...是啊
CameraX/CameraY are tweened by a similar-to-midpoint formula so eventually they'll reach playerx/playery[Cx = (Cx*99+Px)/100]
... yeah
这样一来,每一个对象在舞台的空间移动,变换只在渲染[您节省头痛]
By doing this, every object moves in the stage's space, and is transformed only on render [saving you from headaches]
这篇关于如何渲染2D横向卷轴游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!