charlie_says Posted January 27, 2014 Share Posted January 27, 2014 I'm trying to access the parent (in this case a group) of the clicked entity (in this case a sprite). Is that possible? create: function () { holder1 = game.add.group(); holder1.id = 1; holder1.x = 50; holder1.y = 44; holder1.bg = holder1.create(0, 0, 'bg'); holder1.circ = holder1.create(150, 4, 'circ'); holder1.line = holder1.create(-15, 0, 'line'); holder1.bg.inputEnabled = true; holder1.bg.events.onInputDown.add(this.box_clicked, this); }, update: function() { // }, box_clicked: function(box, pointer) { console.log(this.parent.id);// not working },Is a better way to pass the group in the onInputDown.add? Link to comment Share on other sites More sharing options...
Heppell08 Posted January 27, 2014 Share Posted January 27, 2014 Usually the parent for a group is placed in parenthesis of the add group line. EG:game.add.group(theAdult); and that makes theAdult the parent of the group. If that helps. Link to comment Share on other sites More sharing options...
rich Posted January 27, 2014 Share Posted January 27, 2014 box_clicked: function(box, pointer) { console.log(box.group); }, Link to comment Share on other sites More sharing options...
charlie_says Posted January 27, 2014 Author Share Posted January 27, 2014 Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts