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

Enabling physics on parents & children


joncani
 Share

Recommended Posts

Hey, I'm new to Phaser and running into some trouble getting my bounding boxes to play nice. I'm making a game involving bees and trying to attach a stinger child to the bee parent like so: 

this.beeSprite1.addChild(game.make.sprite(0, 50, assets.stinger1.name));

which successfully attaches the stinger to the bee. My problem is that when I try to use 

this.game.physics.p2.enable(this.beeSprite1);

to to turn on physics (and thus collision) for both of them, I run into problems. The stinger sprite will remain oriented to the bee, but the bounding box will appear at the screen coordinates 0, 50 as a separate physics object. Interacting with it will cause the sprite to move, but moving the sprite by moving the bee that it's attached to won't affect the bounding box. If I try to make the stinger kinematic, the sprite will stay put, but the bounding box will still be stuck at the screen coordinates 0, 50. 

The end goal is to have the stinger be a separate hitbox from the bee, but I'm (clearly) not sure if this is the best way of going about it. Is there something about anchoring bounding boxes that I'm missing, or should I be pursuing this in a different way?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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