Rafaelx 2 Report post Posted January 10, 2017 Trying to create a group, but keeps saying it is undefined got any suggestions? Please see code below. this is defined in the create function: this.bloqueCG = this.game.physics.p2.createCollisionGroup(); makeOneBloque: function(){ this.bloque = this.game.add.group(); this.bloque.enableBody = true; this.bloque.physicsBodyType = Phaser.Physics.P2JS; this.bloque.create(200, 950, 'Blokes'); this.bloque.create(550, 950, 'Blokes'); this.bloque.create(900, 950, 'Blokes'); this.bloque.body.setCollisionGroup(this.bloqueCG); <<<<----I get error here :( this.bloque.body.collides(this.bulletCG, this.hitBloke, this); this.bloque.body.kinematic = true; this.bloque.setAll('anchor.x', 0.5); this.bloque.setAll('anchor.y', 0.5); this.bloque.setAll('outOfBoundsKill', true); this.bloque.setAll('checkWorldBounds', true); }, Share this post Link to post Share on other sites
rich 2,574 Report post Posted January 10, 2017 A Phaser.Group cannot have a Physics Body itself. Think of it as a container, a bucket of Sprites. Each of those Sprites can have a body, but the Group itself doesn't. Share this post Link to post Share on other sites
Rafaelx 2 Report post Posted January 10, 2017 I see so is it possible to give them a body? Share this post Link to post Share on other sites
rich 2,574 Report post Posted January 10, 2017 Not to a Group, no. To any of the child Sprites, yes. Depending on what you're trying to achieve depends on the best way to approach this (it's not immediately obvious from the code above) Share this post Link to post Share on other sites