首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >相位P2 setCollisionGroup

相位P2 setCollisionGroup
EN

Stack Overflow用户
提问于 2016-04-12 22:37:29
回答 1查看 313关注 0票数 0

嗨,我试图让我的子弹碰撞,然后与我的块碰撞而死,但是一旦我尝试setCollisionGroup,我就会得到以下错误:

未定义的TypeError:无法读取未定义的属性“掩码”

它给我指出了这个代码:

代码语言:javascript
复制
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);
    });
},

/.以下是我的另一个碰撞组:

代码语言:javascript
复制
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,然后一切都崩溃了。任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-14 04:16:40

我说错地方了谢谢伙计。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36585327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档