COCOS2DX 3.0-Rewrite "Super Mario" implementation of its six-load interface

Source: Internet
Author: User

This article will use the COCOS2DX texture tool texturepicker, first of all, this part of the material is my own do, very ugly, after all, is not art, and after all, just their own study of the PS side to do. Don't say much nonsense. First read the resources of this article


I'm not using this right here, I'm going to pack it with Texturepicker.

We open Texturepicker to see the following interface


Then drag our game resources to the right sprites area. So, we'll get the interface:


Next, we need to set options on the left. Click the ellipsis button on the left side of the data file to point to your project's resources folder in the popup path and enter Imageresource in the folder's input area



then click Save.


Then find the publish in the toolbar and click.



Then you look at the project directory under the Resourses folder already has 2 files.



Then, go back to our vs above.

Add the following code to the INIT function of the LoadScene.cpp Loadlayer:

<span style= "White-space:pre" ></span>//load resources Spriteframecache *framecache = SpriteFrameCache:: GetInstance (); Framecache->addspriteframeswithfile ("Imageresource.plist", "imageresource.png");//Add Background page Sprite * BG = sprite::createwithspriteframename ("Loading_bg.png"); Bg->setposition (Visiblerect::center ());this-> AddChild (bg,10);//Add the sprite Sprite *loadbar_nomal = Sprite::createwithspriteframename ("Loading_normal.png") in the normal state of loading; Loadbar_nomal->setposition (Visiblerect::center ()); This->addchild (loadbar_nomal,11);//Join Progress bar Loadbar_ Loading = Progresstimer::create (Sprite::createwithspriteframename ("loading_loading.png"));//Initial percentage loadbar_ Loading->setpercentage (0.0f);//coordinate position, usually the same as the position of the above normal state loadbar_loading->setposition (Visiblerect::center ()) ;//set Type Barloadbar_loading->settype (Progresstimer::type::bar),//setbarchangerate method is used to set the direction of the progress bar change, if not the direction of change, The direction is set to 0, otherwise it is set to 1. So (1,0) indicates the transverse direction, (0,1) indicates the longitudinal direction. Loadbar_loading->setbarchangerate (0,1);//setmidpoint method sets the starting point of the progress bar, (0,y) represents the leftmost, (1,y) represents the rightmost, (X,1) indicates the topmost, (x,0) represents the bottom. Loadbar_loading->setmidpoint (Point (0, 0));//Add loadbar_loading to the scene this->addchild (loadbar_loading,12);

Final Run effect






COCOS2DX 3.0-Rewrite "Super Mario" implementation of its six-load 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: 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.