- --绕圆心转动的进度动画
- local function SpriteProgressToRadial()
- local leftProgress = CCProgressTimer:create(CCSprite:create("circle.png"))
- leftProgress:setType(kCCProgressTimerTypeRadial) --扇形顺时针形式
- leftProgress:setPosition(ccp(size.width*0.3,size.height*0.5))
- layer:addChild(leftProgress)
- local progress1 = CCProgressTo:create(10,100)
- leftProgress:runAction(CCRepeatForever:create(progress1))
- local rightProgress = CCProgressTimer:create(CCSprite:create("circle.png"))
- rightProgress:setType(kCCProgressTimerTypeRadial)
- rightProgress:setReverseProgress(true) --扇形逆时针形式
- rightProgress:setPosition(ccp(size.width*0.7,size.height*0.5))
- layer:addChild(rightProgress)
- local progress2 = CCProgressTo:create(10,100)
- rightProgress:runAction(CCRepeatForever:create(progress2))
- end
- --条形
- local function SpriteProgressToHorizontal()
- local to1 = CCProgressTo:create(2,100)
- local to2 = CCProgressTo:create(2,100)
- local left = CCProgressTimer:create(CCSprite:create("man.png"))
- left:setType(kCCProgressTimerTypeBar) --条形 用来设定进度条的显示类型
- left:setMidpoint(ccp(0,0)) --x为0代表进度条从左边开始 setMidpoint:用来设定进度条横向前进的方向从左向右或是从右向左
- left:setBarChangeRate(ccp(1,0)) --y为0代表进度条垂直方向无增长 setBarChangeRate:用来设置进度条增长按横向或是按纵向增长
- left:setPosition(ccp(size.width*0.3,size.height*0.5))
- layer:addChild(left)
- left:runAction(CCRepeatForever:create(to1))
- local right = CCProgressTimer:create(CCSprite:create("blackgirl.png"))
- right:setType(kCCProgressTimerTypeBar)
- right:setMidpoint(ccp(1,0))
- right:setBarChangeRate(ccp(1,0))
- right:setPosition(ccp(size.width*0.7,size.height*0.5))
- layer:addChild(right)
- right:runAction(CCRepeatForever:create(to2))
- --创建一个见血动画 两图片资源:一个为雪条 一个为雪条底 ,雪条底在雪条的上面,通过逐渐显示出雪条底以达到血减少的效果
- local blood = CCSprite:create("hello_hp_1.png")
- blood:setPosition(ccp(size.width*0.5,size.height*0.3))
- layer:addChild(blood)
- local bloodBack = CCProgressTimer:create(CCSprite:create("hello_hp_0.png"))
- bloodBack:setType(kCCProgressTimerTypeBar)
- bloodBack:setMidpoint(ccp(1,0))
- bloodBack:setBarChangeRate(ccp(1,0))
- bloodBack:setPosition(ccp(size.width*0.5,size.height*0.3))
- layer:addChild(bloodBack)
- local to3 = CCProgressTo:create(2,100)
- bloodBack:runAction(CCRepeatForever:create(to3))
- end
- --垂直
- local function SpriteProgressToVertical()
- local to1 = CCProgressTo:create(2,100)
- local to2 = CCProgressTo:create(2,100)
- local left = CCProgressTimer:create(CCSprite:create("man.png"))
- left:setType(kCCProgressTimerTypeBar)
- left:setMidpoint(ccp(0,0)) --x为0从左边开始 为1右边开始,y为0从下面开始 为1从上面开始
- left:setBarChangeRate(ccp(0,1)) --x为1水平变化 y为1垂直变化
- left:setPosition(ccp(size.width*0.3,size.height*0.5))
- layer:addChild(left)
- left:runAction(CCRepeatForever:create(to1))
- local right = CCProgressTimer:create(CCSprite:create("blackgirl.png"))
- right:setType(kCCProgressTimerTypeBar)
- right:setMidpoint(ccp(0,1)) --(0,0)左下角 (0,1)左上角 (1,0)右下角 (1,1)右上角
- right:setBarChangeRate(ccp(0,1))
- right:setPosition(ccp(size.width*0.7,size.height*0.5))
- layer:addChild(right)
- right:runAction(CCRepeatForever:create(to2))
- end
- local function SpriteProgressToRadialMidpointChanged()
- local left = CCProgressTimer:create(CCSprite:create("blocks.png"))
- left:setType(kCCProgressTimerTypeRadial)
- left:setMidpoint(ccp(0.25,0.75))
- left:setPosition(ccp(size.width*0.3,size.height*0.5))
- layer:addChild(left)
- left:runAction(CCRepeatForever:create(CCProgressTo:create(2,100)))
- local right = CCProgressTimer:create(CCSprite:create("blocks.png"))
- right:setType(kCCProgressTimerTypeRadial)
- right:setMidpoint(ccp(0.75,0.25))
- right:setPosition(ccp(size.width*0.7,size.height*0.5))
- layer:addChild(right)
- right:runAction(CCRepeatForever:create(CCProgressTo:create(2,100)))
- end
- local function SpriteProgressVarious()
- local left = CCProgressTimer:create(CCSprite:create("blackgirl.png"))
- left:setType(kCCProgressTimerTypeBar)
- left:setMidpoint(ccp(0.5,0.5))
- left:setBarChangeRate(ccp(1,0))
- left:setPosition(ccp(size.width*0.3,size.height*0.5))
- layer:addChild(left)
- left:runAction(CCRepeatForever:create(CCProgressTo:create(2,100)))
- local middle = CCProgressTimer:create(CCSprite:create("whitegirl.png"))
- middle:setType(kCCProgressTimerTypeBar)
- middle:setMidpoint(ccp(0.5,0.5))
- middle:setBarChangeRate(ccp(1,1))
- middle:setPosition(ccp(size.width*0.5,size.height*0.5))
- layer:addChild(middle)
- middle:runAction(CCRepeatForever:create(CCProgressTo:create(2,100)))
- local right = CCProgressTimer:create(CCSprite:create("man.png"))
- right:setType(kCCProgressTimerTypeBar)
- right:setMidpoint(ccp(0.5,0.5))
- right:setBarChangeRate(ccp(0,1))
- right:setPosition(ccp(size.width*0.7,size.height*0.5))
- layer:addChild(right)
- right:runAction(CCRepeatForever:create(CCProgressTo:create(2,100)))
- end