简体   繁体   English

libGDX重力和恒定加速度无法正常工作

[英]libGDX gravity and constant acceleration doesn't work properly

I am trying to create a simple Flappy Bird clone but in my own way ( so it's not a complete clone ). 我正在尝试以自己的方式创建一个简单的Flappy Bird克隆(因此它不是完整的克隆)。

However I am having problems applying a constant downwards acceleration to the Bird. 但是,我在向Bird施加恒定的向下加速度时遇到了问题。 When I create a World it says that it gets a gravity variable but that's not gravity I think ? 当我创建一个世界时,它说它得到一个引力变量,但这不是引力吗? It should say something like velocity because that is all it does. 它应该说像速度,因为这就是它的全部。 My Bird is falling downwards at a constant speed. 我的鸟儿以恒定的速度下降。 And I believe most of you know how gravity works. 我相信你们大多数人都知道重力是如何工作的。 When I use functions like applyForceTo I basically get the same. 当我使用诸如applyForceTo之类的函数时,我基本上得到了相同的结果。

I have already my own simple implementation of gravity but I wanna use libGDX to its fullest and practice with it. 我已经有了自己简单的重力实现,但是我想充分利用libGDX并进行实践。

I found the answer myself and the solution is pretty simple. 我自己找到了答案,解决方案非常简单。 The objects I render, the whole "System" is way too big for Box2D and its properties to make any difference on the display. 我渲染的对象,整个“系统”对于Box2D及其属性来说太大了,无法在显示上产生任何差异。 Everything accelerates accordingly but you can't see it. 一切都会相应加速,但是您看不到它。 So I scaled down every object so it had properties of a couple of pixels and adjusted the camera. 因此,我按比例缩小了每个对象,使其具有几个像素的属性,并调整了相机。 Now I can get very high accelerations and velocitys. 现在我可以获得很高的加速度和速度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM