Jump to content

Pick up a ball and attach to player in phaser3


phaserly
 Share

Recommended Posts

Hi,

I have the code to pick up a ball with the overlay event.

// in the game.js   

 this.physics.add.overlap(this.ballGroup, this.player, this.ballGroup.collectBalls.bind(this.ballGroup));

// in the ballGroup.js

collectBalls (player, ball) {
    if(player.balls >= 3 || ball.active === false) return;
    ball.active = false;
    ball.visible = false;
    //
    player.balls++;

  }

 

Now i want to stick the ball/image to the player as a 'weapon'. In other words, how to i attach a sprite to another sprite.

Thanks in advance!

 

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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