123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- const lotteryContent = require('../data/lotteryNew');
- const DWTool = require("../utils/DWTool");
- const AlertManager = require('../utils/AlertManager');
- cc.Class({
- extends: cc.Component,
- properties: {
- /// 转盘的title数组 顺时针
- richTextArr: [cc.RichText],
- iconSpriteArr: [cc.Sprite],
- /// 转盘的node
- contentNode: cc.Node,
- drawSpriteFrame: [cc.SpriteFrame],
- drawBgSprite: cc.Sprite,
- drawPointSprite: cc.Sprite,
- ///转盘转的圈数
- _rounds: 4,
- // 转盘转的时间
- _cycleTime: 3,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.node.active = false;
- },
- start () {
- this._localDrawDatas = lotteryContent;
- for (let i = 0; i < lotteryContent.length; ++ i) {
- let drawData = lotteryContent[i];
- /// 根据类型获取抽奖icon
- this.iconSpriteArr[i].SpriteFrame = this.SpriteFrame[drawData.type - 1];
- this.richTextArr[i].string = `<b><color=#4d371f>${drawData.desc}</c></b>`
- }
- this.setUpNotification();
- },
- // hb 抽中的红包金额单位分 是 [long] 查看
- // 4 id 抽中的id 是 [long] 查看
- // 5 name 抽中的名字 是 [string] 查看
- // 6 opt 抽中的具体值(金币倍数或者钻石(type=1该值为金币倍数,type=2该值为钻石)) 是 [int] 查看
- // 7 roomId 抽中的明星所在的房间ID 是 [string] 查看
- // 8 starId 抽中的明细id 是 [string] 查看
- // 9 type
- init(drawData, typeId) {
- this.node.active = true;
- this._drawData = drawData;
- this._typeId = typeId;
- this.setUpSprite(typeId);
- },
- setUpNotification() {
- GameEvent.on("draw_done_action",this, () => {
- this.node.destroy();
- });
-
- GameEvent.on("draw_again", this,(againDrawSuccessData) => {
- this._drawData.drawSuccessData = againDrawSuccessData;
- /// 让它重新滚动
- this.startDraw();
- });
- },
- setUpSprite(typeId) {
- /// 1 2 3
- let bgPath = './textures/draw/draw_cycle_bg_' + typeId;
- let pointPath = './textures/draw/draw_point_' + typeId;
- DWTool.loadResSpriteFrame(bgPath)
- .then((spriteFrame) => {
- this.drawBgSprite.spriteFrame = spriteFrame;
- });
-
- DWTool.loadResSpriteFrame(pointPath)
- .then((spriteFrame) => {
- this.drawPointSprite.spriteFrame = spriteFrame;
- });
- },
-
- startDraw() {
- // 完成
- this.scheduleOnce(function() {
- AlertManager.showDrawSuccessAlert(this._drawData, this._typeId);
- }, this._cycleTime + 0.5);
- let angle = 22.5 + (this._drawData.drawSuccessData.id - 1) * 45;
- var rotateAction = cc.rotateBy(this._cycleTime, angle + 360 * this._rounds);
- this.contentNode.runAction(rotateAction).easing(cc.easeCubicActionOut(this._cycleTime));
- },
- // update (dt) {},
- });
|