JDChi / Flutter-Grid-Lottery

用Flutter实现一个九宫格抽奖 A simple grid lottery widget on Flutter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

抽奖动画处理

cw0925 opened this issue · comments

你好,我现在有新的需求。我现在抽奖界面是7x8的方格,现在是想让抽奖的动画是从上次中奖的位置开始,然后根据移动的步数计算新的中奖位置
` Animation _initSelectIndexTween(
{int begin = 0, int end = 0, Curve curve = Curves.linear}) =>
StepTween(begin: StorageManager.getDiceTarget(), end: end).animate(
CurvedAnimation(parent: _startAnimateController, curve: curve));

_startActualAnimation() {
// _selectedIndexTween = _initSelectIndexTween(
// end: widget.controller.value.repeatRound * _totalIndex +
// widget.controller.value.target,
// curve: Curves.easeOutCubic);
int end = widget.controller.value.target % _totalIndex;
print('真的抽奖动画目标=='+ end.toString());
_selectedIndexTween = _initSelectIndexTween(end: end,curve: Curves.easeOutCubic);
_startAnimateController
..reset()
..duration = widget.controller.value.duration
..forward();
}`
其中_totalIndex = 26;repeatRound = 0;
StepTween(begin: StorageManager.getDiceTarget(), end: end),begin 是本地存储上次中奖的位置。end 是计算的新的中奖位置。从0 到25的动画是正常顺时针转的,但是从25到1的动画却是逆时针转的。就是在转满一圈的时候不知道要怎么处理。
https://github.com/cw0925/Flutter-Grid-Lottery.git,可以看下这个