• 大转盘(CocosCreator)


    推荐阅读:

    1.在场景中搭建大转盘场景,假设
    奖项有n项,对应的每项旋转角度如下:

    第几项 需要旋转的角度
    0 360/n/2
    1 360/n+第0项角度
    2 360/n+第1项角度
    ... ...

    例如:奖项一共6项

    第几项 需要旋转的角度
    0 360/n/2=30
    1 360/n+第一项角度 =30+60=90
    2 90+60=150
    3 210
    4 270
    5 330
    ... ...

    2.代码控制大转盘的转动
    大转盘的思想:预先给定一个本轮大转盘的奖项的下标,然后再随机一个该奖项的角度,核心代码:

    var angle = app.random((idx + 1) * (-60) + 10 + 360, (idx + 0) * (-60) - 10 + 360, false) + 1800;
    

    其中,60代表360/n,上面可以当成一个公式使用。
    旋转函数代码:

        /// 转动大转盘,idx表示奖项的下标
        rollPanel(idx, call) {
            var self = this;
            self.uiRoot.close.active = false;
            self.uiRoot.begin.enabled = false;
            var angle = app.random((idx + 1) * (-60) + 10 + 360, (idx + 0) * (-60) - 10 + 360, false) + 1800;
            var rot1 = cc.rotateTo(5, angle).easing(cc.easeExponentialInOut(10.0));
            var call1 = app.callFunc(function (adt) { self.uiRoot.close.active = true; self.uiRoot.begin.enabled = true; if (call) { call(); } });
            this.uiRoot.panel.root.stopAllActions();
            this.uiRoot.panel.root.rotation %= 360;
            this.uiRoot.panel.root.runAction(cc.sequence(rot1, call1));
        },
    
  • 相关阅读:
    数据库-自定义函数
    数据库-存储过程
    数据库配置
    水电费管理系统需求分析与设计_待完善
    SQL中Group By的使用
    部分查询功能语句
    10-11数据库练习
    Oracle-SQL
    开发环境之Gradle
    解决程序端口占用
  • 原文地址:https://www.cnblogs.com/shirln/p/10605412.html
Copyright © 2020-2023  润新知