美文网首页
AS3 :转盘实现

AS3 :转盘实现

作者: 一眼就认出你 | 来源:发表于2019-06-14 15:50 被阅读0次

    代码如下:

            //转动的位置
            private var _index: Number;
    
            //初始化游戏
            private function init():void{
                _index=0;
            }
    
            //点击事件触发转动
             private function clickHandler(event:Event): void {
                 _index=++_index%8;
                 console.log(" 下标 "+_index);
                 startRotate();
             }
    
             /**开始转动奖励盘 */
            private function startRotate(): void {
                _luckRollerViewUI.arrowBox.rotation = 0;
                var destination: Number = 1440 + (9-_index) * 45 ;
                var a: Tween = Tween.to(_luckRollerViewUI.arrowBox, { "rotation": destination }, 4000, Ease.quadOut, Handler.create(this, function ():void {
                      Tween.clear(a);
                }));
            }
    

    解释:
    arrowBox:转动装盘的图片变量
    rotation:转动的角度
    1440 + (9-_index) * 45 :用于装盘转动
    1440 + _index * 45 :用于指针转动
    (注意:1440是360的2倍->转两圈 45*8=360,代表8个分片,若是6个分片,改为60即可 )
    Tween.to:缓动
    Ease.quadOut:缓动函数类型

    相关文章

      网友评论

          本文标题:AS3 :转盘实现

          本文链接:https://www.haomeiwen.com/subject/norpfctx.html