Cocos2d-x version 3.6 Loading interface

Source: Internet
Author: User

Then the resource is loaded.
The previous section tells you how to create a background with a picture. is actually creating a genie. In Cocos2d-x, background, characters, props, see a lot of objects are actually an elf.

When a resource is loaded, it usually makes a loading interface that tells the user that the resource is now loading. Of course there are many students to write tutorials, only write how to implement the loading interface, how to load resources and did not write, this is not comprehensive.

Let me first talk about how to complete a loading interface.

Put loading's picture into the project and add an index to the Resources.h.
Then modify the Startgame init function as follows:

BOOL Startgame:: Init(){///First Parent class init function    ///Here you know, the init () function is an inherited function, and it is a virtual function that subclasses can override this function    if(!Layer:: Init() ) {return false; }//Get screen viewable areaSize visiblesize=Director:: getinstance() -Getvisiblesize ();//Create a loading iconAuto Loading=Sprite:: Create(S_loading_logo);//Set position to center positionLoading -SetPosition (visiblesize.Width/ 2, visiblesize.Height/ 2);//Add to current layerAddChild (loading);//Set initial transparency diagramLoading -SetOpacity ( -);//A dark-to-bright animationAuto FadeIn=FadeIn:: Create(3);//Create a repeating animationLoading -Runaction (RepeatForever:: Create(Sequence:: Create(FadeIn, FadeIn -Reverse (),NULL)));return true;}

See, create a loading sprite first, and this is the same as creating a background. Then give it an animation, which consists of several actions.
The first is a dark-to-Ming animation, note that to achieve this animation, you must first set a transparency, otherwise there is no change, because the loading wizard comes out by default is bright.
Then flip the animation, then create a sequence animation with these two animations, which is to lighten and darken first. Then use this sequence animation to create a repeating animation repeatforever.

All right, that's it.

The loading interface is implemented, and the next section tells how to load resources in the background when loading.

Cocos2d-x version 3.6 Loading interface

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.