Sign in to follow this  
MZuex

Problems setting up collision between group children

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();
    }

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.