Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

抽奖动画处理 #2

Open
cw0925 opened this issue Oct 8, 2021 · 0 comments
Open

抽奖动画处理 #2

cw0925 opened this issue Oct 8, 2021 · 0 comments

Comments

@cw0925
Copy link

cw0925 commented Oct 8, 2021

你好,我现在有新的需求。我现在抽奖界面是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,可以看下这个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant