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

Method getChildByProp

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

* return the child corresponding to the given property and value. * note : avoid calling this function every frame since * it parses the whole object tree each time * @param {string} prop - Property name * @param {string|RegExp|number|boolean} value - Value of the property * @returns {

(prop, value, objList = [])

Source from the content-addressed store, hash-verified

617 * let inViewport = container.getChildByProp("inViewport", true);
618 */
619 getChildByProp(prop, value, objList = []) {
620 this.forEach((child) => {
621 const v = child[prop];
622 if (value instanceof RegExp && typeof v === "string") {
623 if (value.test(v)) {
624 objList.push(child);
625 }
626 } else if (v === value) {
627 objList.push(child);
628 }
629 if (child instanceof Container) {
630 child.getChildByProp(prop, value, objList);
631 }
632 });
633
634 return objList;
635 }
636
637 /**
638 * returns the list of children with the specified class type

Callers 5

getChildByNameMethod · 0.95
getChildByGUIDMethod · 0.95
container.spec.jsFile · 0.80
postDrawMethod · 0.80
postDrawMethod · 0.80

Calls 2

forEachMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected