• CCProgressTo和CCProgressTimer


    在cocos2d中同样提供了很多表现图片和精灵的方式,上一篇当中提到的切换场景的方式之一是顺或逆时针切入的方法,在图片上也可以使用,test里有一个例子介绍CCProgressTimer可以实现一些图片的特效效果,这样的效果可以在载入的时候作为载入动画

    步骤1.定义CCProgressTo,通过actionWithDuration函数,第一个参数是时间是一个CCTime对象,第二个参数是结果显示图片的百分比,如例子中一个100%,一个50%

    步骤2 定义CCProgressTimer,通过progressWithFile,参数是图片路径

    步骤3 调用setType设置类型,

    kCCProgressTimerTypeRadialCW   顺时针生成

    kCCProgressTimerTypeRadialCCW  逆时针生成

    kCCProgressTimerTypeHorizontalBarLR 从左到右生成

    kCCProgressTimerTypeHorizontalBarRL 从右到左生成

    kCCProgressTimerTypeVerticalBarBT 从下到上生成

    kCCProgressTimerTypeVerticalBarTB 从上到下生成

    步骤4:设置位置,没什么好说的,直接setPosition

    步骤5:开始,使用CCRepeatForever(重复进行),传入CCProgressTo对象

    刚开始研究此引擎,如有错误之处,希望大家多多指正

    下一篇写一下test类里面的其他场景


       CCProgressTimer *progress1=CCProgressTimer::create(CCSprite::create("Icon.png"));

        progress1->setPosition(ccp(100,100));

        //设置进度条的样式

        progress1->setType(kCCProgressTimerTypeRadial);

        //设置进度值范围[0,100]

        progress1->setPercentage(100);

        //反进度计时

        progress1->setReverseProgress(true);

        this->addChild(progress1);

       

        //第一个参数是时间,第二个参数是表示旋转100%

        CCProgressTo *to1 = CCProgressTo::create(10, 100);

        progress1->runAction(to1);

       

        //------------------------------------------

        CCProgressTimer *progress2=CCProgressTimer::create(CCSprite::create("Icon.png"));

        progress2->setPosition(ccp(200,100));

        //设置进度条的样式

        progress2->setType(kCCProgressTimerTypeBar);

        //设置计时器运动方向

        progress2->setMidpoint(ccp(0,1));

        //设置计时器的宽高起始比例

        progress2->setBarChangeRate(ccp(0, 1));

       

        this->addChild(progress2);

       

        //第一个参数是时间,第二个参数是表示旋转100%

        CCProgressTo *to2 = CCProgressTo::create(10, 100);

        progress2->runAction(to2); 

    转自:http://www.2cto.com/kf/201305/212168.html

  • 相关阅读:
    telnet linux 参数
    telnet服务 linux机器
    how to learn
    mysql关键字
    linux 下iptables配置详解
    C#调用开源图像识别类库tessnet2
    netty入门实例
    android布局属性详解
    安卓高手之路之ClassLoader(四)
    安卓高手之路之 GDI图形引擎篇
  • 原文地址:https://www.cnblogs.com/wodehao0808/p/3600058.html
Copyright © 2020-2023  润新知