samme Posted September 21, 2016 Share Posted September 21, 2016 GitHub / NPM group.onChildAdded.add(function (child, parent){ /* `child` was added to `parent` */ }); group.onChildRemoved.add(function (child, prevParent){ /* `child` was removed from `prevParent` */ }); group.onChildKilled.add(function (child, parent){ /* `child` was killed */ }); group.onChildRevived.add(function (child, parent){ /* `child` was revived */ }); Link to comment Share on other sites More sharing options...
tips4design Posted September 21, 2016 Share Posted September 21, 2016 Cool. In which cases would you use those? Child-adding is a synchronous task and you are usually the one doing it in the code so you could just call a function after you add it. Link to comment Share on other sites More sharing options...
samme Posted September 23, 2016 Author Share Posted September 23, 2016 Hi tips, definitely, you could; I suppose it helps with separation of concerns and could simplify complex relationships. I wanted to find a way some interested entity could monitor a group without ever having to visit its children. I think the biggest advantage is you can respond to changes in children created after you've attached to the signal, forever. It also reduces signal volume for very large groups. Slightly interesting: `onChildAdded` is triggered by auto-expanding Bullet groups and createIfNull: true. And you can monitor every game object by binding just 4 signals on `game.world`. Link to comment Share on other sites More sharing options...
Recommended Posts