COCOS2D-X-changing digital effect Demo

Source: Internet
Author: User

When we are playing "everyday Love elimination" or "Everyday livemix", a game result page is displayed after each game disk, showing the score obtained. today, our Demo is to achieve similar results. i. We directly add code in the HelloCpp project of the COCOS2D-X. we add the following code in Initialization: [cpp] CCSize szWin = CCDirector ctor: sharedDirector ()-> getVisibleSize (); CCLabelAtlas * pNumLabl = CCLabelAtlas: create ("0123456789 ", "fonts/fonts. plist "); // here is the graph word Plist file addChild (pNumLabl,); pNumLabl-> setPosition (ccp (szWin. width/2-200, szWin. height/2); schedule (schedule_selector (HelloWorld: step); // Timer 2. Then we need to implement the function called by a timer. the Code is as follows: [cpp] void HelloWorld: step (float Dt) {static int nDelta = 0; // note that this static local variable will only initialize nDelta + = 11 once; // note that no overflow is handled here. handle the specific situation in char StringOfNum [20]; sprintf (StringOfNum, "% 03d", nDelta); CCLabelAtlas * pNumLabl = static_cast <CCLabelAtlas *> (getChildByTag (1000 )); pNumLabl-> setString (StringOfNum);} 3. Add note ①. when creating the CCLabelAtlas object, we pass the Plist file of the graph word. fonts cannot be directly transferred here. put the plist file in the Resource folder. the path must be resource/XXX/fonts. plist. cause: [cpp] bool CCLabelAtlas: initWithString (const char * theString, const char * fntFile) {std: string pathStr = CCFileUtils: sharedFileUtils () -> fullPathForFilename (fntFile); std: string relPathStr = pathStr. substr (0, pathStr. find_last_of ("/") + "/"; // COCOS2D-X and wood have not found here "/" corresponding processing ********************** *********************** * ************} ②. Download link of the graph file involved in the program http://t.cn/z863wnjPS : Because it is basic learning, no analysis has been made. More exciting content will be available in the future. Please pay attention to my solemn statement as follows: 1. This article is from the CDN blog. http://t.cn/z863ASQ Ii. All Rights Reserved. This statement shall not be removed when any individual or website reposts this article. 3. You shall not modify the article unless explicitly stated.

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.