繁体   English   中英

闪光飞轮AS3

[英]Spinning Wheel in flash AS3

我想在FLASH中创建(轮盘)纺车模拟。

我想得到一个数字,该(轮盘赌)旋转轮将停在指示器的前面。

这是演示我实际想要的链接。 http://zytwebdev.zoomyourtraffic.in/amol_zytwebdev/roullete/R1_wheel2.swf

section = new Array();

section[0] = "1";
section[1] = "2";
section[2] = "3";
section[3] = "4";
section[4] = "5";
section[5] = "6";
section[6] = "7";
section[7] = "8";
section[8] = "9";
section[9] = "10";
section[10]= "11";
section[11]= "12";
section[12]= "13";
section[13]= "14";
section[14]= "15";
rotate = 0;

//button press
button.onPress = function()
{
    spinWheel();
}

//create a function to speed the wheel, slow it down, stop then display result
function spinWheel()
{
    speed = 10; //the speed the wheel rotates
    count = 0;
    button.enabled = false; //while the wheel is spinning disable the button
    limit = random(40)+10; //random time for the wheel to spin before slowing down
    onEnterFrame = function()
    {
        rotate += speed;
        degrees = rotate; // DEBUG print the rotation

        //trace(degrees+" Deg");
        if (rotate>359)
        {
            rotate = rotate - 360;
        }
        //slow the wheel down
        if (count>limit)
        {
            if (speed>0)
            {
                speed -= 1.3
            } 
            else
            {
                //stop the wheel
                speed = 0;
                onEnterFrame = false;
                button.enabled = true; //enable the button

                prize = section[Math.floor(rotate/24)] ; //display the result
                printsection = Math.floor(rotate/24); // DEBUG print the section number
                trace(prize);
            }
        }
        //move wheel if speed is greater than 0
        if (speed>0){
            wheelHolder.wheel._rotation = rotate;
            count++;
        }
    }
}

这是相同的工作代码。

任何帮助对我都很重要。 提前致谢。

我为这个简单的轮子4ya疯狂。 http://b3vad.persiangig.com/Drop/Untitled-1.swf

package {

import flash.display.MovieClip;
import flash.events.MouseEvent;


public class main extends MovieClip {


    public function main() {
        addEventListener(MouseEvent.CLICK,clcks);
    }

    public function clcks(e:MouseEvent):void {
        if (e.target.name == "doit") {
            var rr = Math.round(Math.random()*360);
            spn.rotation=-rr;
            spn.play();
            trace(Math.round(rr/22.5));
        }
    }
}

}

将360度划分为多种可能性。 尝试将其保留为整数值,但这不是必需的。

使用TweenLite或TweenMax进行旋转。 我确定您想要的内容有一个摘要。 否则,请使用宽松的设置。

当滚轮停止并触发onComplete事件时,请查看旋转在阵列中的位置。

就像将360分成36个选项一样,每个元素之间的角度为10度。 因此54旋转意味着它位于第5个元素(向下舍入)。 旋转249即表示第24个元素。

你只是做

Math.floor( myWheel.rotation / ( 360 / myArrayOfOptions.length ) )

获取myArrayOfOptions的索引。

您可以从那里拿走。

干杯!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM