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

Working with Groups. Hard to make sense of this error.


kriket
 Share

Recommended Posts

I am making platforms and assigning them to a group. 

 
 create: function() {    this.playerCollisionGroup = this.game.physics.p2.createCollisionGroup();    this.stationaryCollisionGroup = this.game.physics.p2.createCollisionGroup();            //  PLATFORMS    this.stationary = this.game.add.group();    this.stationary.enableBody = true;    this.stationary.createMultiple(125, 'climb');    this.stationary.physicsBodyType = Phaser.Physics.P2JS;    for(var i = 0; i < this.stationary.children.length; i++){            this.stationary.children[i].body.setCollisionGroup(this.stationaryCollisionGroup);            this.stationary.children[i].body.collides(this.playerCollisionGroup);    }}
But this gives me the error:

Uncaught TypeError: this.stationary.children[i].body.setCollisionGroup is not a function

 

I thought this would work. Can anyone help me find out why this is not working?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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