Source: Internet
Author: User

I want to implement a function. A love filling effect.

The effect is as follows:

<喎?http: kf ware vc " target="_blank" class="keylink"> VcD4KPHA + examples/examples + PGJyPgo8L3A + examples/examples + ZG90YbXAvt/A5Mi00Ke5 + example + examples + vfi2yLXExcnJ + example/cnPw + authorization + uL20 + M28xqzXytS0OjxpbWcgc3JjPQ = "" alt = "\"> (heart_a.png1_(heart_ B .png)

// Create two genie, one white border and one gradually increasing red-hearted CCSprite * psSprite1 = CCSprite: create ("heart_A.png"); CCSprite * psSprite2 = CCSprite :: create ("heart_ B .png"); // loading action, set to 5 seconds to load to 100% CCProgressTo * progressTo = CCProgressTo: create (5,100); CCProgressTimer * heart _ = CCProgressTimer :: create (psSprite2); // set the heart _-> setType (kCCProgressTimerTypeBar); // the start point. heart _-> setMidpoint (ccp (0, 0); // ccp (1, 0) Horizontal Direction ccp (0, 1) vertical heart _-> setBarChangeRate (ccp (0, 1); psSprite1-> setPosition (ccp (size. width/2,500); addChild (psSprite1); heart _-> setPosition (ccp (size. width/2,500); addChild (heart _); heart _-> runAction (CCRepeatForever: create (progressTo ));

The specific operation is provided in the Code. Very simple.

In addition, pay attention to it.

In 2.0, the type of CCProgressTimer is much less than that of 1.0. In 1.0, there are:

KCCProgressTimerTypeRadialCW generate kCCProgressTimerTypeRadialCCW kCCProgressTimerTypeHorizontalBarLR kCCProgressTimerTypeHorizontalBarRL kkkk stststststststststimertypeverticalbarbt from bottom to bottom

In 2.0, only two common ones are retained.

typedef enum { /// Radial Counter-Clockwise kCCProgressTimerTypeRadial, /// Bar kCCProgressTimerTypeBar,} CCProgressTimerType;

However, to achieve some effects, such as loading from bottom to top. Just like the example program I provided. You only need to set the corresponding setMidpoint and setBarChangeRate.

// Start point. heart _-> setMidpoint (ccp (0, 0); // ccp (1, 0) Horizontal Direction ccp (0, 1) vertical heart _-> setBarChangeRate (ccp (0, 1 ));

On the way to learning, I will share with you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.