zoukankan      html  css  js  c++  java
  • 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);

        //设置计时器运动方向 第一个參数表示x比例第二个表示y比例

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

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

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

       

        this->addChild(progress2);

       

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

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

        progress2->runAction(to2);


  • 相关阅读:
    北京理工大学复试上机--2014
    北京理工大学复试上机--2013
    北京理工大学复试上机--2012
    北京理工大学复试上机--2011
    北京理工大学复试上机--2010
    Python的逻辑结构和函数
    Python的概述
    BOM
    正则表达式的匹配
    jQuery的插件和跨域、ajax
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4853426.html
Copyright © 2011-2022 走看看