Could you please demonstrate how to control the speed of a ball using buttons for speeding up and slowing down? I have tried implementing the code but it does not seem to be working correctly.
this.speedUpButton = this.add.sprite(230, 530, 'down-bubble').setInteractive({ cursor: 'pointer' });
this.speedDownButton = this.add.sprite(80, 530, 'up-bubble').setInteractive({ cursor: 'pointer' });
this.input.on('gameobjectup', function (pointer, gameobject) {
if (gameobject === this.speedDownButton && this.ballSpeed > 100)
{
this.ballSpeed -= 10.1;
}
else if (gameobject === this.speedUpButton && this.ballSpeed < 19.9)
{
this.ballSpeed += 10.1;
}
});
adjustBallSpeed() {
this.ballSpeed = 0.003;
return this.tweens.addCounter({
from: 220,
to: 160,
duration: 9000,
delay: 2000,
ease: 'Sine.easeInOut',
repeat: -1,
yoyo: true
});
}