1 decade ago by UziMonkey
I wanted something a bit more expressive than ig.Entity.TYPE.A and ig.Entity.TYPE.B, so I made this plugin. Now you can do things like ig.Entity.TYPE.get('enemy') instead. Entities can have multiple types and can collide with multiple types.
It doesn't change anything about type A and B types, you can keep using them as you wish and mix in the new entity types. It also doesn't change anything about how ImpactJS works. All the functionality was there, it just didn't have an interface to define new names easily.
You can read more about it on my blog, and code is below.
It doesn't change anything about type A and B types, you can keep using them as you wish and mix in the new entity types. It also doesn't change anything about how ImpactJS works. All the functionality was there, it just didn't have an interface to define new names easily.
You can read more about it on my blog, and code is below.
ig.module( 'plugins.entitytype' ).requires( 'impact.entity' ).defines(function() { ig.Entity.TYPE._next = 4; ig.Entity.TYPE.get = function(name) { if( name.indexOf(" ") != -1 ) { type = 0; types = name.split(' '); for( i = 0; i < types.length; i++ ) { type |= ig.Entity.TYPE.get(types[i]); } return type; } if(!ig.Entity.TYPE.hasOwnProperty(name) ) { ig.Entity.TYPE[name] = ig.Entity.TYPE._next; ig.Entity.TYPE._next <<= 1; } return ig.Entity.TYPE[name]; } })