这个转盘动画更加的真实,添加了指针动画,类似炉石匹配时那个随着转盘转,打到指针让指针动起来的效果,由于图片大小限制,录制的帧率控制的很低,展示效果不是很理想
大致思路:这个转盘每格是等分的,所以只需要知道最终停留的id(1~10)位置,然后获取到对应角度
动画分启动加速,匀速,缓慢停止三个阶段,都是用差值来实现缓动效果的,其他细节直接看代码吧
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BigPrizePool : MonoBehaviour
{
public Transform roll, point;
public InputField inputNum;
//开始标志
bool startFlag = false, stopCoroutineFlag = true;
//每个区域的角度
float poolZoneAngle = 36;
int idx = 1;
// Start is called before the first frame update
void Start()
{
}
//转盘动画
IEnumerator RollAnimation(int endNum)
{
while (!startFlag)
{
yield return null;
}
float startTime = Time.time;