KonceptZer0 Posted June 6, 2016 Share Posted June 6, 2016 I'm trying to detect collisions between sprites within the same group and use the callback function to turn them immovable: game.physics.arcade.collide(platforms, platforms, makeImmovable(), null, game); function makeImmovable(piece1, piece2){ piece1.body.immovable=true; //CRASHING HERE piece2.body.immovable=true; } It's crashing with a "Uncaught TypeError: Cannot read property "body" of undefined" on the commented line. What could it be? Link to comment Share on other sites More sharing options...
shohan4556 Posted June 7, 2016 Share Posted June 7, 2016 I think your platforms group did not have any arcade physics. So that its didn't found the body property. try this , var platforms = game.add.group(); platforms.enablebody = true; then try again. Link to comment Share on other sites More sharing options...
drhayes Posted June 7, 2016 Share Posted June 7, 2016 In the line "game.physics.arcade.collide(platforms, platforms, makeImmovable(), null, game);", you are not passing the function "makeImmovable" you are *calling* the function. Take the parenthesis away, like this: "game.physics.arcade.collide(platforms, platforms, makeImmovable, null, game);". Link to comment Share on other sites More sharing options...
Recommended Posts