如何向幸运轮添加声音

时间:2019-02-19 09:44:30

标签: javascript json

我想在转盘上添加滴答声。我在Google上找到了此代码,但我不知道如何以及在何处实现它。

 // function to spin the wheel
spinWheel(){
    // can we spin the wheel?
    if(this.canSpin){
        // resetting text field
        this.prizeText.setText("");
        // the wheel will spin round from 2 to 4 times. This is just coreography
        var rounds = Phaser.Math.Between(16, 64);
        // then will rotate by a random number from 0 to 360 degrees. This is the actual spin
        var degrees = Phaser.Math.Between(0, 360);
        // before the wheel ends spinning, we already know the prize according to "degrees" rotation and the number of slices
        var prize = gameOptions.slices - 1 - Math.floor(degrees / (360 / gameOptions.slices));
        // now the wheel cannot spin because it's already spinning
        this.canSpin = false;
        // animation tweeen for the spin: duration 3s, will rotate by (360 * rounds + degrees) degrees
        // the quadratic easing will simulate friction
        this.tweens.add({
            // adding the wheel to tween targets
            targets: [this.wheel],
            // angle destination
            angle: 360 * rounds + degrees,
            // tween duration
            duration: gameOptions.rotationTime,
            // tween easing
            ease: "Cubic.easeOut",
            // callback scope
            callbackScope: this,

0 个答案:

没有答案