MCPcopy Create free account
hub / github.com/melonjs/melonJS / update

Method update

packages/melonjs/src/renderable/container.js:1114–1151  ·  view source on GitHub ↗

* container update function. * automatically called by the application update loop Application * @protected * @param {number} dt - time since the last update in milliseconds. * @returns {boolean} true if the Container is dirty

(dt)

Source from the content-addressed store, hash-verified

1112 * @returns {boolean} true if the Container is dirty
1113 */
1114 update(dt) {
1115 let isFloating = false;
1116 const isPaused = state.isPaused();
1117 const children = this.getChildren();
1118 const childrenLength = children.length;
1119 const cameras = state.current().cameras;
1120
1121 for (let i = childrenLength, obj; i--, (obj = children[i]); ) {
1122 if (isPaused && !obj.updateWhenPaused) {
1123 // skip this object
1124 continue;
1125 }
1126
1127 isFloating = globalFloatingCounter > 0 || obj.floating;
1128 if (isFloating) {
1129 globalFloatingCounter++;
1130 }
1131
1132 // check if object is in any active cameras
1133 obj.inViewport = false;
1134 // iterate through all cameras
1135 cameras.forEach((camera) => {
1136 if (camera.isVisible(obj, isFloating)) {
1137 obj.inViewport = true;
1138 }
1139 });
1140
1141 // update our object
1142 this.isDirty |= (obj.inViewport || obj.alwaysUpdate) && obj.update(dt);
1143
1144 if (globalFloatingCounter > 0) {
1145 globalFloatingCounter--;
1146 }
1147 }
1148
1149 // call the parent method
1150 return super.update(dt);
1151 }
1152
1153 /**
1154 * draw this renderable (automatically called by melonJS)

Callers

nothing calls this directly

Calls 4

getChildrenMethod · 0.95
currentMethod · 0.45
forEachMethod · 0.45
isVisibleMethod · 0.45

Tested by

no test coverage detected