Jump to content

Debug a sprite body from a group


Cary Crusiau
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...