In order to move nodes into position after physics have taken place I’d like to have an ‘after-step’ event in physics manager.
This way I can make motion streaks look correct.
Here’s an example with update/lateUpdate
late-update
and one with an after-step event
after-step
CCPhysicsManager.js example
update: function (dt) {
var world = this._world;
if (!world || !this.enabled) return;
this.emit('before-step');
this._steping = true;
var velocityIterations = PhysicsManager.VELOCITY_ITERATIONS;
var positionIterations = PhysicsManager.POSITION_ITERATIONS;
if (this.enabledAccumulator) {
this._accumulator += dt;
// max accumulator time to avoid spiral of death
if (this._accumulator > MAX_ACCUMULATOR) {
this._accumulator = MAX_ACCUMULATOR;
}
while (this._accumulator > FIXED_TIME_STEP) {
world.Step(FIXED_TIME_STEP, velocityIterations, positionIterations);
this._accumulator -= FIXED_TIME_STEP;
}
}
else {
var timeStep = 1/cc.game.config['frameRate'];
world.Step(timeStep, velocityIterations, positionIterations);
}
world.DrawDebugData();
this._steping = false;
var events = this._delayEvents;
for (var i = 0, l = events.length; i < l; i++) {
var event = events[i];
event.target[event.func].apply(event.target, event.args);
}
events.length = 0;
this._syncNode();
this.emit('after-step');
},