MZuex Posted May 15, 2018 Share Posted May 15, 2018 Hi Guys, AM having problems setting up collisions between children of a group I created. I can have have them collide with other gameobjects but not with each other. This is the code I have inside my Create function, am I missing something? create: function () { myObjects = this.physics.add.staticGroup(); var mychildObjects = this.textures.get('myObjects').getFrameNames(); var y=400; for (var i = 0; i < 5; i++) { var x=400; y+=260; for (var j=0; j<5; j++){ var image = this.add.image(x, y, 'myObjects', Phaser.Math.RND.pick(mychildeObjects)); image.setInteractive(); this.input.setDraggable(image); myObjects.add(image); x+=260; } } this.physics.add.overlap(myObjects, myObjects, this.checkCollision, null, this); this.input.on('drag', function (pointer, gameObject, dragX, dragY) { gameObject.x=dragX; gameObject.y=dragY; } ); }, checkCollision:function(object1, object2){ console.log("inside"); object1.destroy(); } Link to comment Share on other sites More sharing options...
samme Posted May 15, 2018 Share Posted May 15, 2018 Don't use a static group for that. Or else `refresh` the group in the drag handler. Turn on physics debugging to see where the bodies are. Link to comment Share on other sites More sharing options...
MZuex Posted May 15, 2018 Author Share Posted May 15, 2018 Solved, thanks Link to comment Share on other sites More sharing options...
Recommended Posts