• 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

  • 相关阅读:
    【BZOJ 2120】 数颜色
    【BZOJ 1878】 HH的项链
    【BZOJ 2038】小Z的袜子
    【BZOJ 2724】 蒲公英
    【POJ 2482】 Stars in Your Windows
    【POJ 2182】Lost Cows
    __align(num) 分析
    C# 获取图片某像素点RGB565值
    基于OpenCV的火焰检测(三)——HSI颜色判据
    基于OpenCV的火焰检测(一)——图像预处理
  • 原文地址:https://www.cnblogs.com/newlist/p/3207406.html
Copyright © 2020-2023  润新知