cocos2d-x lua ProgressTimer

本文详细介绍了如何在Cocos2d-x的Lua环境中使用ProgressTimer组件来创建不同类型的下载进度条,如圆形、水平和垂直进度条,并展示了相应的配置方法。
摘要由CSDN通过智能技术生成

cocos2d-x lua ProgressTimer 下载进度条 使用

function test()
    local layer = cc.Layer:create()

    local to1 = cc.ProgressTo:create(2, 100)
    local to2 = cc.ProgressTo:create(2, 100)
    local path1 = "Jms_PetSystem/img/passMailIcon.png"
    -- RADIAL 圆形进度
    local test1 = cc.ProgressTimer:create(cc.Sprite:create(path1))
    test1:setType(cc.PROGRESS_TIMER_TYPE_RADIAL)
    test1:setPosition(cc.p(100, display.height / 2))
    test1:runAction(cc.RepeatForever:create(to1))
    layer:addChild(test1)

    --Horizontal 水平进度
    local test2 = cc.ProgressTimer:create(cc.Sprite:create(path1))
    test2:setType(cc.PROGRESS_TIMER_TYPE_BAR)
    -- right:setReverseDirection(true)
    test2:setMidpoint(cc.p(1, 0))
    test2:setBarChangeRate(cc.p(1, 0))
    test2:setPosition(cc.p(display.width - 100, display.height / 2))
    test2:runAction(cc.RepeatForever:create(to2))
    layer:addChild(test2)

    -- Vertical 从下到上 从上到下 修改test3:setMidpoint(cc.p(0, 0)) 点就行
    local test3 = cc.ProgressTimer:create(cc.Sprite:create(path1))
    test3:setType(cc.PROGRESS_TIMER_TYPE_BAR)
    -- Setup for a bar starting from the bottom since the midpoint is 0 for the y
    test3:setMidpoint(cc.p(0, 1))
    -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
    test3:setBarChangeRate(cc.p(0, 1))
    test3:setPosition(cc.p(display.width - 300, display.height / 2))
    test3:runAction(cc.RepeatForever:create(to2))
    layer:addChild(test3)

    self:addChild(layer)
end
 

  • 9
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值