Jump to content

Newbie problems with Physics (Arcade)


totallybueno
 Share

Recommended Posts

Hi there, I´m having some problems with the physics in my game and I don´t know why... I´m gonna tell you

 

I have a group and a sprite created this way

this.group1 = this.game.add.group();this.group1.enableBody = true;this.group1.physicsBodyType = Phaser.Physics.ARCADE;this.sprite1 = this.game.add.sprite(0,0, "sprite1");this.game.physics.enable(this.sprite1, Phaser.Physics.ARCADE);this.game.physics.startSystem(Phaser.Physics.ARCADE);

I check for collisions in the update function and everything works fine, this way

this.game.physics.arcade.collide(this.sprite1 , this.group1 , this.callback1, null, this);

Then, I create a second sprite this way

this.sprite2 = this.game.add.sprite(0,0, "weapon");this.game.physics.enable(this.sprite2, Phaser.Physics.ARCADE);this.sprite2.body.velocity.y = 200;

And I check for collisions in the update function this way, but it doesn´t work...

this.game.physics.arcade.collide(this.sprite1 , this.sprite2, this.callback2, null, this);

Something that I´m missing? Both bodies have velocity... I don´t know if the need something else :(

Link to comment
Share on other sites

Well, after you comment I checked and... it was a scope problem :angry:

 

Sorry for this (actually "this" was the problem), I should check that before posting this... anyway, if a moderator sees this, please delete de post :)

 

Thanks lewster32, the thing is that you helped me to find and fix my bug :D

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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