添加新的抽奖动画
This commit is contained in:
parent
154b8cfa19
commit
de731b9c15
|
|
@ -42,6 +42,13 @@ export default {
|
|||
times: 0, // 动画运行次数计数
|
||||
targetIndex: 0, // 最终中奖索引
|
||||
isFinalWin: false, // 是否到达最终中奖状态
|
||||
animationType: 1, // 动画类型:1=顺序遍历,2=8字形
|
||||
path8Index: 0, // 8字形路径当前位置
|
||||
animationTypes: {
|
||||
SEQUENTIAL: 1, // 顺序遍历
|
||||
FIGURE_EIGHT: 2 // 8字形走法
|
||||
},
|
||||
pathFigureEight: [0, 1, 2, 5, 4, 3, 6, 7, 8, 5, 4, 3], // 8字形路径
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -59,6 +66,15 @@ export default {
|
|||
// 重置计数和速度
|
||||
this.times = 0;
|
||||
this.speed = 100;
|
||||
this.path8Index = 0;
|
||||
|
||||
// 随机选择动画类型:1-2之间
|
||||
this.animationType = Math.floor(Math.random() * 2) + 1;
|
||||
let animationName = "顺序遍历";
|
||||
if (this.animationType === this.animationTypes.FIGURE_EIGHT) {
|
||||
animationName = "8字形";
|
||||
}
|
||||
console.log('抽奖动画类型:', animationName);
|
||||
|
||||
// 随机生成中奖索引(0-8之间)
|
||||
this.targetIndex = Math.floor(Math.random() * 9);
|
||||
|
|
@ -71,8 +87,15 @@ export default {
|
|||
this.timer = setInterval(() => {
|
||||
this.times++;
|
||||
|
||||
// 选择下一个格子
|
||||
this.currentIndex = (this.currentIndex + 1) % 9;
|
||||
// 根据不同的动画类型选择下一个格子
|
||||
if (this.animationType === this.animationTypes.SEQUENTIAL) {
|
||||
// 顺序遍历方式
|
||||
this.currentIndex = (this.currentIndex + 1) % 9;
|
||||
} else {
|
||||
// 8字形路径
|
||||
this.path8Index = (this.path8Index + 1) % this.pathFigureEight.length;
|
||||
this.currentIndex = this.pathFigureEight[this.path8Index];
|
||||
}
|
||||
|
||||
// 动画速度控制
|
||||
if (this.times > 20) { // 前20次保持高速
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user