Jump to content

Collision. How to?


Recommended Posts

Hello, I'm creating my first HTML5 game with Phaser. I have some problems with collision detection. For now, I have an image:


this.currentElf = this.add.image(this.elfFront.x, this.elfFront.y, this.elfFront.key);


and I have a group of other sprites:

this.presents = this.add.group();


then I create sprites in this group:

var pr = this.presents.create(x, y, 'present');


And here is my update: function:

update: function() {
        this.physics.arcade.overlap(this.presents, this.currentElf, this.elfCollision, null, this);
Here is function that is called when these sprites overlap:
elfCollision: function(pr, el) {
My question would be, what settings do I need to set, that this collision would work? I tried to set  presets.enableBody = true. I also tried to use:
this.physics.enable(this.currentElf, Phaser.Physics.Arcade)
But it doesn't work, I don't know why.
It would be great if someone could explain, cause I think I miss a single detail here.
Link to comment
Share on other sites


  • Recently Browsing   0 members

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