Home » Jquery » javascript – Wheel JS not include Array-Exceptionshub

javascript – Wheel JS not include Array-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

Hello developers,

I try to make a Spin and Win game. I Have library for this game. ( http://dougtesting.net/home ). I Try to assign array to ‘segments’ values. This code working now..

In my game there is 12 pieces at the wheel and each pieces has different prices with different values. and ı want to know if there is a chance to control the possibility of the frequency.Like the price with the biggest value is has to be the rarest price in my game.

let theWheel = new Winwheel({
            'numSegments'  : 12,     // Specify number of segments.
            'outerRadius'  : 212,   // Set outer radius so wheel fits inside the background.
            'textFontSize' : 28,    // Set font size as desired.
            'segments'     :        // Define segments including colour and text.
            [
               {id: "1", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "2", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "3", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "4", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "5", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "6", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "7", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "8", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "9", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "10", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "11", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
               {id: "12", text: "5.000 Miles", count: "10", appid: "1", fillStyle: "#9a0606"},
            ],
            'animation' :           // Specify the animation to use.
            {
                'type'     : 'spinToStop',
                'duration' : 15,
                'spins'    : 12,
                'callbackFinished' : alertPrize,
                'callbackSound'    : playSound,   // Function to call when the tick sound is to be triggered.
                'soundTrigger'     : 'pin'        // Specify pins are to trigger the sound, the other option is 'segment'.
            },
            'pins' :
            {
                'number' : 12   // Number of pins. They space evenly around the wheel.
            }
        });

MY ARRAY ( Array Variable Name = GiftArray )

id: "1", text: "10.000 Miles", count: "10", appid: "1"
id: "2", text: "5.000 Miles", count: "10", appid: "1"
id: "3", text: "2.500 Miles", count: "10", appid: "1"
id: "4", text: "1.000 Miles", count: "10", appid: "1"
id: "5", text: "500 Miles", count: "10", appid: "1"
id: "6", text: "250 Miles", count: "10", appid: "1"
id: "7", text: "10.000 Miles", count: "10", appid: "1"
id: "8", text: "5.000 Miles", count: "10", appid: "1"
id: "9", text: "2.500 Miles", count: "10", appid: "1"
id: "10", text: "1.000 Miles", count: "10", appid: "1"
id: "11", text: "500 Miles", count: "10", appid: "1"
id: "12", text: "250 Miles", count: "10", appid: "1"

This code not Working..

let theWheel = new Winwheel({
                'numSegments'  : 12,    
                'outerRadius'  : 212,  
                'textFontSize' : 28,   
                'segments'     : GiftArray, // GIFT ARRAY MY ARRAY NAME
                'animation' :           
                {
                    'type'     : 'spinToStop',
                    'duration' : 15,
                    'spins'    : 12,
                    'callbackFinished' : alertPrize,
                    'callbackSound'    : playSound,   
                    'soundTrigger'     : 'pin'        
                },
                'pins' :
                {
                    'number' : 12  
                }
            });
How to&Answer: