Jump to content

Collisions with extended Sprite object


mariogarranz
 Share

Recommended Posts

I had a game prototype which worked just fine.

 

Then, when refactoring and tyding up code, the player object stopped detecting collisions against the tile map, as well as overlapping with certain objects. It still detected collisions against world bounds though.

After some tests, I noticed that if I replaced this code in the State:

 

update: function(){  this.game.physics.arcade.collide(this.player, this.collisionLayer, this.playerCollides, null, this);  ...}

With this code in the extended Sprite class:
 

MyGame.Player.prototype.update = function(){  this.game.physics.arcade.collideSpriteVsTilemapLayer(this, this.collisionLayer);...};

It works.



Any idea on why is this happening? I would like to keep some of the overlapping checks inside the State update function, not in the Player update.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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