Cocos2d-x 2.x progress bar CCProgressTimer

Source: Internet
Author: User

Cocos2d also provides a lot of ways to express images and genie. One of the methods mentioned in the previous article is to switch scenes in a forward or backward direction, which can also be used in images, there is an example in "test" that describes how CCProgressTimer achieves special effects on some images. Such effects can be used as loading animations during loading.

 

 

Step 1. Define CCProgressTo. Through the actionWithDuration function, the first parameter is the time is a CCTime object, and the second parameter is the percentage of the result display image. For example, a 100%, a 50%

Step 2 define ccprogresstfile and use progressWithFile. The parameter is the image path.

Step 3 call setType to set the type,

KCCProgressTimerTypeRadialCW clockwise generation

KCCProgressTimerTypeRadialCCW is generated counterclockwise.

KCCProgressTimerTypeHorizontalBarLR is generated from left to right.

KCCProgressTimerTypeHorizontalBarRL is generated from right to left.

KCCProgressTimerTypeVerticalBarBT is generated from bottom to top.

KCCProgressTimerTypeVerticalBarTB generated from top to bottom

Step 4: Set the position. There is nothing to say. Set the position directly.

Step 5: start by using CCRepeatForever (repeated) to pass in the CCProgressTo object

I just started to study this engine. If there are any errors, I hope you can correct them more.

Next, let's take a look at other scenarios in the test class.

 

 

 


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

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

// Set the style of the progress bar

Progress1-> setType (kCCProgressTimerTypeRadial );

// Set the progress value range to [0,100]

Progress1-> setPercentage (100 );

// Reverse progress timing

Progress1-> setReverseProgress (true );

This-> addChild (progress1 );

// The first parameter is the time, and the second parameter is the rotation 100%

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

Progress1-> runAction (to1 );

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

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

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

// Set the style of the progress bar

Progress2-> setType (kCCProgressTimerTypeBar );

// Sets the direction of the timer.

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

// Set the start ratio of the timer width and height

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

This-> addChild (progress2 );

// The first parameter is the time, and the second parameter is the rotation 100%

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

Progress2-> runAction (to2 );


 

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: info-contact@alibabacloud.com 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.