I’m trying to learn Phaser3. I made a few games but neglected to score. Now I’m trying to add scoring, but I’m having a problem because I’m using the overlapping of the ball and the players, where the scoring increases as long as there is contact between the ball and the players. I would like the rectangle to act as a point if possible.
This is a piece of code:
this.num=0;
this.scoreText=this.add.text(16, 16, 'Score: ',{font: '40px Arial', fill:'#000' });
this.scoreNum=this.add.text(140, 16, this.num ,{font: '40px Arial', fill:'#000' });
___________________________________________________
let btackaRect = this.btacka.getBounds();
let loptaRect = this.lopta.getBounds();
if ( Phaser.Geom.Intersects.RectangleToRectangle(btackaRect, loptaRect) )
{
// if ( Phaser.Geom.Rectangle.Overlaps(btackaRect, loptaRect ))
// {
this.kos.anims.play('tres');
this.scoreText;
this.scoreNum;
this.scoreNum.setText( this.num ) ;
this.num++;
return;
}