我正在使用PhysicsJS来动画身体对某些力量作出反应。因此,我想使用applyForce()
对身体施加一个力量。
对我而言似乎它只适用于第一帧。当我启动脚本时,身体应该获得恒定的永久力,以“推动”方向以恒定速度移动。
我想我必须在正确的函数中“包装”rect1.applyForce()
以永久地调用它。你知道我怎么做吗?
到目前为止,这是我的代码:
Physics(function(world){
//some Code
//forces
rect1.applyForce({x:0.2,y:0})
// subscribe to ticker to advance the simulation
Physics.util.ticker.on(function( time, dt ){
world.step( time );
});
// start the ticker
Physics.util.ticker.start();
});
任何帮助将不胜感激!