1 decade ago by Zetaphor
Hello everyone, I've got a small hangup that's stopping me from progressing, I appreciate any help you can give.
In short, I'm attempting to read ig.game.entities from a class which is instantiated as an object within an entity. The problem is ig.game is returning null.
The class is stored in a separate file in a subfolder under entities. I'm requiring it within my entity file. I can see that it is executing, but it fails when I attempt to reference the entities list for iteration.
In short, I'm attempting to read ig.game.entities from a class which is instantiated as an object within an entity. The problem is ig.game is returning null.
The class is stored in a separate file in a subfolder under entities. I'm requiring it within my entity file. I can see that it is executing, but it fails when I attempt to reference the entities list for iteration.
ig.module( 'game.entities.components.target' ) .requires( 'impact.game' ) .defines(function(){ ig.component_target = ig.Class.extend({ findCreature: function(self,options,distance){ console.log(MyGame); var results = new Array(); for(var i = 0; i < ig.game.entities.length; i++) { var ent = this.entities[i]; for(o_property in options){ if (ent.properties[o_property] == self.properties[o_property]){ results.push(ent); } } if (!results.length){ return false; } else{ return results; } } } }); });