1 decade ago by Mediamonkey
Hey all,
I&
This makes it possible to check the inheritance of two uninstantiated classes, like so:
console.log( ig.MyGame.inheritance.indexOf(ig.Game.classId) > -1 );
This works like instanceof, but on a class level. If you output a class's inheritance array you'll see all the inherited class id's as a sort of breadcrumbs.
I've needed this for a level change manager where I did not want to instantiate a level yet, but did want to check if the type was allowed into the manager. I guess in AS3 this would be checked by using the "is" operator.
I&
039;ve added 2 lines to the core impact.js file at line
548Class.parentId = prototype.parentId = (!!parent) ? parent.classId : [lastClassId]; Class.inheritance = prototype.inheritance = (!!parent && !!parent.inheritance) ? parent.inheritance.concat(parent.classId) : [];
This makes it possible to check the inheritance of two uninstantiated classes, like so:
console.log( ig.MyGame.inheritance.indexOf(ig.Game.classId) > -1 );
This works like instanceof, but on a class level. If you output a class's inheritance array you'll see all the inherited class id's as a sort of breadcrumbs.
I've needed this for a level change manager where I did not want to instantiate a level yet, but did want to check if the type was allowed into the manager. I guess in AS3 this would be checked by using the "is" operator.