Skip to content

Commit 5def58d

Browse files
committed
Added pins and tick to wheel of fortune example
1 parent cfd17bc commit 5def58d

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

examples/wheel_of_fortune/index.html

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,34 @@ <h1>Winwheel.js example wheel - wheel of fortune</h1>
115115
'animation' : // Specify the animation to use.
116116
{
117117
'type' : 'spinToStop',
118-
'duration' : 8, // Duration in seconds.
118+
'duration' : 10, // Duration in seconds.
119119
'spins' : 3, // Default number of complete spins.
120-
'callbackFinished' : alertPrize
121-
}
120+
'callbackFinished' : alertPrize,
121+
'callbackSound' : playSound, // Function to call when the tick sound is to be triggered.
122+
'soundTrigger' : 'pin' // Specify pins are to trigger the sound, the other option is 'segment'.
123+
},
124+
'pins' : // Turn pins on.
125+
{
126+
'number' : 24,
127+
'fillStyle' : 'silver',
128+
'outerRadius': 4,
129+
}
122130
});
123131

132+
// Loads the tick audio sound in to an audio object.
133+
var audio = new Audio('tick.mp3');
134+
135+
// This function is called when the sound is to be played.
136+
function playSound()
137+
{
138+
// Stop and rewind the sound if it already happens to be playing.
139+
audio.pause();
140+
audio.currentTime = 0;
141+
142+
// Play the sound.
143+
audio.play();
144+
}
145+
124146
// Vars used by the code in this page to do power controls.
125147
var wheelPower = 0;
126148
var wheelSpinning = false;
@@ -183,7 +205,7 @@ <h1>Winwheel.js example wheel - wheel of fortune</h1>
183205
}
184206
else if (wheelPower == 3)
185207
{
186-
theWheel.animation.spins = 9;
208+
theWheel.animation.spins = 10;
187209
}
188210

189211
// Disable the spin button so can't click again while wheel is spinning.

examples/wheel_of_fortune/tick.mp3

2.34 KB
Binary file not shown.

0 commit comments

Comments
 (0)