Jump to content

Problem extending the Group class and ARCADE


totallybueno
 Share

Recommended Posts

Hi there,

I´m having a few problems with something related with a group and Arcade physics, let me explain. I have a prefab extending the normal group, the idea is that I need to add some graphics here in differente layers and one of them, the background should act the de physics sprite, I mean, this one should be the one detecting collisions, the rest of the graphics would be just that, graphics.

I create this item like this:

Ribbon = function (game, posX, posY) {
    //
    //other code
    //
    Phaser.Group.call(this, game); 
    this.myBackground = this.create(this.posX, this.posY, "my-background");
    this.enableBody = true;
    this.physicsBodyType = Phaser.Physics.ARCADE
    //
    //and more code
    //
};

And then in the main game .js I call it and everything is placed correctly in the stage but the collisions are not working at all (I also using the render() and no green overlay at all). I´m adding a (extended) group into another group and I´m not doing it right obviously :(

this.ribbonGroup = this.game.add.group()
this.myRibbon = new Ribbon(this.game, posX, posY)
this.ribbonGroup.add(this.myRibbon)
/*this.ribbonGroup.enableBody = true;
this.ribbonGroup.physicsBodyType = Phaser.Physics.ARCADE*/

The item is there, well place, animations working, everything is fine but the physics part, what am I missing here?

 

Thanks in advance.

Link to comment
Share on other sites

Maybe I´m missing something, but still same result. Now I have the Ribbon prefab like this:

Ribbon = function (game, posX, posY) {
    //
    //other code
    //
    Phaser.Group.call(this, game); 
    this.myBackground = this.create(this.posX, this.posY, "my-background");
    game.physics.arcade.enable(this.myBackground)//line you told me
    //
    //and more code
    //
};

But as I said, still same result. Should I add something when I creat the item in the Game.js?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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