|
|
@@ -5,7 +5,7 @@ import TurnableItem from "./TurnableItem";
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
/**
|
|
|
* 转盘
|
|
|
- * @author 邹勇
|
|
|
+ * @author 邹勇 kaka
|
|
|
*/
|
|
|
@ccclass
|
|
|
export default class Turnable extends cc.Component {
|
|
|
@@ -22,6 +22,13 @@ export default class Turnable extends cc.Component {
|
|
|
|
|
|
private audioId: number;
|
|
|
|
|
|
+ private endAngle = 0
|
|
|
+ private startDraw = false
|
|
|
+ private slowDis = 720
|
|
|
+ private slowAngle = 0
|
|
|
+ private perAdd = 10
|
|
|
+ private perMinus = 0
|
|
|
+
|
|
|
onLoad() {
|
|
|
this.initData();
|
|
|
}
|
|
|
@@ -42,24 +49,33 @@ export default class Turnable extends cc.Component {
|
|
|
|
|
|
/** 点击抽奖 */
|
|
|
clickDraw() {
|
|
|
- if (gData.turnable.leftTimes > 0) {
|
|
|
- mk.ad.watchAd((success: boolean) => {
|
|
|
- mk.console.log("watchAD:" + success);
|
|
|
- if (success) {
|
|
|
- gData.adData.watchVideo(AdFun.turntable);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ // if (gData.turnable.leftTimes > 0) {
|
|
|
+ // mk.ad.watchAd((success: boolean) => {
|
|
|
+ // mk.console.log("watchAD:" + success);
|
|
|
+ // if (success) {
|
|
|
+ // gData.adData.watchVideo(AdFun.turntable);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ this.play(2);
|
|
|
}
|
|
|
|
|
|
private async play(index) {
|
|
|
this.audioId = await mk.audio.playEffect("turnableplay", true);
|
|
|
this.btn_close.getComponent(BtnClosePanel).block_click = true;
|
|
|
- this.node_turn.angle = 1800;
|
|
|
- let tar = index * 60;
|
|
|
- cc.tween(this.node_turn)
|
|
|
- .to(3, { angle: tar })
|
|
|
- .call(this.playOver, this).start();
|
|
|
+
|
|
|
+ this.perAdd = 10
|
|
|
+ this.node_turn.angle += 360 * 5
|
|
|
+ this.endAngle = index * -60
|
|
|
+ this.slowAngle = this.endAngle + this.slowDis
|
|
|
+ this.perMinus = this.perAdd / (this.slowDis / (this.perAdd * 0.5))
|
|
|
+ this.startDraw = true
|
|
|
+
|
|
|
+ // this.node_turn.angle = 1800;
|
|
|
+ // let tar = index * 60;
|
|
|
+ // cc.tween(this.node_turn)
|
|
|
+ // .to(3, { angle: tar })
|
|
|
+ // .call(this.playOver, this).start();
|
|
|
}
|
|
|
|
|
|
private playOver() {
|
|
|
@@ -83,6 +99,23 @@ export default class Turnable extends cc.Component {
|
|
|
gData.reward.data = gData.turnable.adData;
|
|
|
gData.turnable.adData = null;
|
|
|
}
|
|
|
+
|
|
|
+ if (this.startDraw) {
|
|
|
+ this.node_turn.angle -= this.perAdd
|
|
|
+ //开始减速
|
|
|
+ if (this.node_turn.angle <= this.slowAngle) {
|
|
|
+ if (this.perAdd <= this.perMinus * 4) {
|
|
|
+ this.perAdd -= this.perMinus * 0.01
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.perAdd -= this.perMinus
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.node_turn.angle <= this.endAngle) {
|
|
|
+ this.startDraw = false
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
onDestroy() {
|