creator有没有可以直接设置的系统参数,让所有运动物体的速度都提升?
还是说需要单独去设置node.getComponent(cc.RigidBody).linearVelocity的速度值?
多谢多谢,我研究下先,蛤
好像没起作用,我想通过按钮控制来让RigidBody加速运动
不明白楼主这样做的意义。
一定要的话,我觉得可以遍历获得场景内所有RigidBody,然后设置相应属性试试。
为了减少等待时间,压缩不需要操作的演示阶段
多次调用update就能达到多次刷新物理引擎的效果
我刚测试了确实是可用的
多次调用?具体是怎么做啊,求教!~~
let physicsManager = cc.director.getPhysicsManager();
physicsManager.enabledAccumulator = true;
把enabledAccumulator设置为true,然后在你的update函数里调用
let physicsManager = cc.director.getPhysicsManager()
physicsManager.enabled = true;
physicsManager.update(2.0*dt);
physicsManager.enabled = false;
可以达到加速的效果,跟我说的多次调用是一个效果
具体看api的描述,又时间你可以看看CCPhysicsManager.js里的源码
/**
* !#en
* Specify the fixed time step.
* Need enabledAccumulator to make it work.
* !#zh
* 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。
* @property {Number} FIXED_TIME_STEP
* @default 1/60
* @static
*/
FIXED_TIME_STEP: 1/60,
/**
* !#en
* If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP.
* And if the update dt is bigger than the time step, then will call step function several times.
* If disabled accumulator, then will call step function with a time step calculated with the frame rate.
* !#zh
* 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。
* 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。
* @property {Boolean} enabledAccumulator
* @default false
*/
this.enabledAccumulator = false;
2赞
实测可用,可是有时候会抖动,有更好的方法吗