Cary Crusiau Posted June 26, 2014 Share Posted June 26, 2014 Hello, Here is a part of my code:create: function() {this.hedgehogs = game.add.group();this.hedgehogs.createMultiple(10, 'hedgehog');},update: function() {if (this.game.time.now > this.Time) {this.addHedgehog();this.Time = game.time.now + 2000;}},addHedgehog: function() {var hedgehog = this.hedgehogs.getFirstDead();game.physics.arcade.enable(hedgehog);hedgehog.body.setSize(95, 61, 7, 6);},How can I debug the 'body' of the 'hedgehog'? I tried:game.debug.body(hedgehog);game.debug.body(this.hedgehog);But none of them work. Any help? TIA Link to comment Share on other sites More sharing options...
lewster32 Posted June 26, 2014 Share Posted June 26, 2014 addHedgehog: function() { // we need to access the current hedgehog outside of this function, so use 'this' to // attach it to the state instead this.currentHedgehog = this.hedgehogs.getFirstDead(); game.physics.arcade.enable(this.currentHedgehog); this.currentHedgehog.body.setSize(95, 61, 7, 6); }, render: function() { // ensure we have a current living hedgehog otherwise we'll get errors if (this.currentHedgehog && this.currentHedgehog.alive) { // show the body for the current hedgehog game.debug.body(this.currentHedgehog); } } Link to comment Share on other sites More sharing options...
Cary Crusiau Posted June 27, 2014 Author Share Posted June 27, 2014 Thank you very much lewster32! Works like a charm now! lewster32 1 Link to comment Share on other sites More sharing options...
Recommended Posts