Spawn new block

hi all, here I’m trying to make a stack tower game using Phaser 3, but I’m having a hard time to spwans a new block when the previous block has stopped. please help because I’m still new to studying in Phaser 3.

Create :

speed = 4;

cube = this.add.sprite(300,650, "cGame").setInteractive();
cube.setScale(0.2);
cube.on('pointerdown', function ()
{
       speed = (speed === 0);

 });

this.time.delayedCall(0, this.startInputEvents, [], this);

Update :

cube.x = cube.x + speed;

if (cube.x > 520) {
    speed = -speed;
}
else if (cube.x < 80) {
    speed = -speed;
    }