dudeperfect Posted December 28, 2014 Share Posted December 28, 2014 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) { pr.kill(); } 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 More sharing options...
lenlac Posted December 28, 2014 Share Posted December 28, 2014 I would check out this example: http://examples.phaser.io/_site/view_full.html?d=arcade%20physics&f=sprite+vs+group.js&t=sprite%20vs%20group Link to comment Share on other sites More sharing options...
Recommended Posts