Not sure if topic makes sense, but I’ll do better explaining it here.
I have two arrays, one called prizes and the other called zoneStarts.
this.prizes = ['2.5', '5', '10', '20', '30', '50', '100', '150', '250', '500', 'rubies', 'boost'];
this.zoneStarts = [126, 65.9, -143.9, 36.1, -53.8, 156.3, -173.8, 6.1, -119.7, 96.1, -83.8, -23.7];
I have a function that grabs a random value from prizes and puts it into a switch case that randomly picks an angle within the zone for that prize that I want my prize wheel to stop at. I am trying to add a function that will cause the wheel to go to a full stop when it’s velocity is under a certain value and the wheel rotates past the start of the selected prize zone.
SpinManager.prototype.pick = function()
{
prize = this.prizes[Math.floor(Math.random()*this.prizes.length)];
switch(prize)
{
case '2.5':
this.targetAngle = Math.round(pc.math.random(126, 144));
break;
case '5':
this.targetAngle = Math.round(pc.math.random(65.9, 83.9));
break;
case '10':
this.targetAngle = Math.round(pc.math.random(-143.9, -126));
break;
case '20':
this.targetAngle = Math.round(pc.math.random(36.1, 53.9));
break;
case '30':
this.targetAngle = Math.round(pc.math.random(-53.8, -36));
break;
case '50':
this.targetAngle = Math.round(pc.math.random(156.3, 173.8));
break;
case '100':
this.targetAngle = Math.round(pc.math.random(-173.8, -156.2));
break;
case '150':
this.targetAngle = Math.round(pc.math.random(6.1, 23.9));
break;
case '250':
this.targetAngle = Math.round(pc.math.random(-113.7, -96.1));
break;
case '500':
this.targetAngle = Math.round(pc.math.random(96.1, 113.8));
break;
case 'rubies':
this.targetAngle = Math.round(pc.math.random(-83.8, -66.1));
break;
case 'boost':
this.targetAngle = Math.round(pc.math.random(-23.7, -6.1));
break;
}
this.fullStop = this.zoneStarts[prize]; //The line in question
};
Let’s say prize is position 1 in the prizes array (2.5), I want fullStop to be position 1 in the zoneStarts array (126). Am I doing this right here, or do I need to change it somehow?