标签:
1、图片资源
zhuanpanSpr:111.png
indicatorSpr:222.png
2、转盘数据
1 local zhuanpanData = 2 { 3 {start = 0,ended=44}, 4 {start = 45,ended=89}, 5 {start = 90,ended=134}, 6 {start = 135,ended=179}, 7 {start = 180,ended=224}, 8 {start = 225,ended=269}, 9 {start = 270,ended=314}, 10 {start = 315,ended=359}, 11 }
3、目标
1 local targetIdx = 5
4、转动持续时间
1 local duration = 5
5、转动圈数
1 local rotateNum = 5
6、增加到场景
1 local zhuanpan = display.newSprite(zhuanpanSpr) 2 :addTo(self) 3 :pos(512,384) 4 local indicator = display.newSprite(indicatorSpr) 5 :addTo(self) 6 :pos(512,384+zhuanpan:getContentSize().height/2)
7、转动
1 scheduler.performWithDelayGlobal(function(dt) 2 local targetData = zhuanpanData[targetIdx] 3 local rotateAngle = 360*rotateNum+math.random(targetData.start,targetData.ended) 4 local action = cc.RotateBy:create(duration, rotateAngle) 5 local easeAction = cc.EaseCubicActionInOut:create(action) 6 zhuanpan:runAction(easeAction) 7 end, 0.5)
8、效果
标签:
原文地址:http://www.cnblogs.com/Androider123/p/4280007.html