I want to implement a function. A love filling effect.
The effect is as follows:
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + examples/examples + PGJyPgo8L3A + examples/examples + ZG90YbXAvt/A5Mi00Ke5 + example + examples + vfi2yLXExcnJ + example/cnPw + authorization + uL20 + M28xqzXytS0OjxpbWcgc3JjPQ = "http://www.2cto.com/uploadfile/Collfiles/20140322/2014032208265130.png" 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.