MCPcopy Index your code
hub / github.com/KilledByAPixel/LittleJS / engineObjectsUpdate

Function engineObjectsUpdate

src/engine.js:469–497  ·  view source on GitHub ↗

Update each engine object, remove destroyed objects, and update time * can be called manually if objects need to be updated outside of main loop * @memberof Engine

()

Source from the content-addressed store, hash-verified

467 * can be called manually if objects need to be updated outside of main loop
468 * @memberof Engine */
469function engineObjectsUpdate()
470{
471 // get list of solid objects for physics optimization
472 engineObjectsCollide = engineObjects.filter(o=>o.collideSolidObjects);
473
474 // recursive object update
475 function updateChildObject(o)
476 {
477 if (o.destroyed) return;
478
479 o.update();
480 for (const child of o.children)
481 updateChildObject(child);
482 }
483 for (const o of engineObjects)
484 {
485 if (o.parent || o.destroyed) continue;
486
487 // update top level objects
488 o.update();
489 o.updatePhysics();
490 for (const child of o.children)
491 updateChildObject(child);
492 o.updateTransforms();
493 }
494
495 // remove destroyed objects
496 engineObjects = engineObjects.filter(o=>!o.destroyed);
497}
498
499/** Destroy and remove all objects
500 * - This can be used to clear out all objects when restarting a level

Callers 1

engineUpdateFunction · 0.85

Calls 4

updateChildObjectFunction · 0.85
updateMethod · 0.45
updatePhysicsMethod · 0.45
updateTransformsMethod · 0.45

Tested by

no test coverage detected