After recently delving into TypeScript, I found myself encountering an error in my code for a wheel mini-game on my app. The specific error being displayed in the console is:
this.easeOut is not a function
The relevant portion of the code causing the issue is as follows:
spin() {
const spinAngleStart = Math.random() * 10 + 10;
this.spinTime = 0;
this.spinTimeTotal = Math.random() * 3 + 4 * 1000;
this.rotateWheel(spinAngleStart);
}
rotateWheel(spinAngleStart: number){
this.spinTime += 30;
if(this.spinTime >= this.spinTimeTotal) {
this.stopRotateWheel();
return;
}
*const spinAngle = spinAngleStart - this.easeOut(this.spinTime, 0, spinAngleStart, this.spinTimeTotal);*
this.startAngle += (spinAngle * Math.PI / 180);
this.drawRouletteWheel();
console.log(this.spinTimeTotal);
console.log(this.spinTime);
this.spinTimeout = setTimeout(this.rotateWheel, 30);
}
easeOut(t, b, c, d) {
const ts = (t /= d) * t;
const tc = ts * t;
console.log(ts);
console.log(tc);
return (b+c * (tc + -3*ts + 3*t));
}
Despite easeOut() residing within the same scope as rotateWheel(), the specified error points to the line highlighted with asterisks.
The error specifically targets the line marked with asterisks