Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Problems setting up collision between group children


MZuex
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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