[英]How to move “obstacle” objects. Corona SDK Physics Box2D. Physics Update?
I'm trying to understand the proper way to move "obstacle" objects in corona/box2d. 我正在尝试了解在corona / box2d中移动“障碍”对象的正确方法。 I want to know how to write my code so that the movement is deterministic and in-step with the physics engine.
我想知道如何编写代码,以便运动是确定性的,并且与物理引擎同步。 Is this possible?
这可能吗?
I'm familiar with Unity which has a physics update (FixedUpdate). 我熟悉具有物理更新(FixedUpdate)的Unity。 Where you can add a bit of code to execute on every physics step.
您可以在其中添加一些代码以在每个物理步骤上执行。 This keeps the physics deterministic, frame and system time independent.
这使物理确定性,框架和系统时间保持独立。
For example, in my game I want to do things like: Make a platform that moves back and forth, make an object that scales up and down in size. 例如,在我的游戏中,我想做以下事情:创建一个可以前后移动的平台,制作一个可以按比例缩放的对象。 I would still like the physics to work properly and allow the ball in my game to bounce off of these for example.
我仍然希望物理工作正常,例如,允许游戏中的球弹起。 Depending on the case, I imagine that I should use either kinematic or dynamic bodies .
我视情况而定,我应该使用运动学的或动态的物体 。
I've searched around and the way to periodically manipulate these objects is to use: 我搜索了一下,定期操作这些对象的方法是使用:
I don't think that any of these will behave deterministic. 我认为这些都不是确定性的。 Any suggestions?
有什么建议么? Thanks for the help.
谢谢您的帮助。
You should really use: 您应该真正使用:
object:setLinearVelocity(xVelocity, yVelocity)
or 要么
object:applyForce(xForce, yForce)
instead of transition.to. 而不是过渡到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.