【原】quick-cocos2d-x 3.3 實現轉盤

一、圖片資源dom

  zhuanpanSpr:111.pngspa

    
  indicatorSpr:222.pngcode

    

二、轉盤數據orm

 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         }

三、目標blog

1 local targetIdx = 5

四、轉動持續時間圖片

1 local duration = 5

五、轉動圈數資源

1 local rotateNum = 5

六、增長到場景get

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)

七、轉動it

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)

八、效果io

相關文章
相關標籤/搜索