嗨,我试图让我的子弹碰撞,然后与我的块碰撞而死,但是一旦我尝试setCollisionGroup,我就会得到以下错误:
未定义的TypeError:无法读取未定义的属性“掩码”
它给我指出了这个代码:
createBullets: function(){
//Bullets
this.bullets = this.add.group();
this.bullets.enableBody = true;
this.bullets.physicsBodyType = Phaser.Physics.P2JS;
this.bullets.createMultiple(500, 'bullet', 0, false);
this.bullets.setAll('anchor.x', 0.5);
this.bullets.setAll('anchor.y', 0.5);
this.bullets.setAll('outOfBoundsKill', true);
this.bullets.setAll('checkWorldBounds', true);
this.bullets.forEach(function(bullet){
bullet.body.setCollisionGroup(this.bulletsCG); <-------This line
bullet.body.collides(this.bloquesCG);
});
},/.以下是我的另一个碰撞组:
addOneBloque: function(x, y) {
this.bloque = this.add.sprite(x,y,'bloque');
this.physics.p2.enable(this.bloque, false);
this.bloque.body.velocity.x = -200;
this.bloque.checkWorldBounds = true;
this.bloque.outOfBoundsKill = true;
this.bloque.body.setCollisionGroup(this.bloquesCG);
this.bloque.body.collides(this.bulletsCG, this.resetBullet, this);
},一切都正常,直到我尝试setCollisionGroups,然后一切都崩溃了。任何帮助都将不胜感激。
发布于 2016-04-14 04:16:40
我说错地方了谢谢伙计。
https://stackoverflow.com/questions/36585327
复制相似问题