MCPcopy Create free account
hub / github.com/codemistic/Web-Development / spinwheel

Function spinwheel

SpinWheel-Santa/JS/game.js:159–209  ·  view source on GitHub ↗
(check)

Source from the content-addressed store, hash-verified

157let gametune = new Audio('Assets/tune.mp3');
158
159function spinwheel(check){
160
161 // can we spin the wheel?
162 if(this.canSpin){
163
164 //clap pause here
165 clap.pause();
166 // star
167 tick.play();
168
169 //game tune
170 gametune.play();
171
172 //player cannot spin
173 this.canSpin=false;
174
175 console.log("You clicked the mouse");
176 console.log("Start spinning");
177 //this.game_text.setText("You clicked the mouse!");
178
179 let rounds = Phaser.Math.Between(2,4);
180 let degrees = Phaser.Math.Between(0,11)*30;
181
182 let total_angle = rounds*360 + degrees;
183 console.log(total_angle);
184
185 let idx = prizes_config.count - 1 - Math.floor(degrees/(360/prizes_config.count));
186
187
188 tween = this.tweens.add({
189 targets: this.wheel,
190 angle: total_angle,
191 ease: "Cubic.easeOut",
192 duration: 6000,
193 callbackScope:this,
194 onComplete:function(){
195
196 //pause game tune
197 // gametune.pause();
198
199 //clap play here
200 clap.play();
201 this.game_text.setText("You got : " + prizes_config.prize_names[idx]);
202 // clap.pause();
203 // player can spin again
204 this.canSpin=true;
205 // clap.play();
206 },
207 });
208 }
209}

Callers

nothing calls this directly

Calls 1

logMethod · 0.45

Tested by

no test coverage detected