Cocos2d-x using Ccclippingnode to realize the marquee

Source: Internet
Author: User

Directly in the code, which is a good package layer that can be called directly//originally in vain

BOOL Testlayer::init () {ccsize size = Ccdirector::shareddirector ()->getvisiblesize ();    Create the text to be displayed text = Cclabelttf::create ("text\nbaibai\nfdffdd\nzimu\nhaha\njahjahjkd\njhahaj\n", "", 30);    Text->setposition (CCP (100,-120));    Draw clipping area ccdrawnode* Shap = Ccdrawnode::create ();    Ccpoint Point[4] = {CCP (0,0), CCP (0), CCP (n, N), CCP (0, 200)};    Shap->drawpolygon (Point, 4, ccc4f (355, 255, 255, 255), 2, ccc4f (255, 255, 255, 255));    ccclippingnode* cliper = Ccclippingnode::create ();    Cliper->setstencil (Shap);    Cliper->setanchorpoint (CCP (. 5,. 5));    Cliper->setposition (CCP (100, 20));    AddChild (cliper);//Add the text to be scrolled to the clipping area cliper->addchild (text); Text scrolling. Schedule (Schedule_selector (Ctestlayer::rolltext)) after the range has been exceeded, return true; void Testlayer::rolltext (float) {text->getpositiony () >300? Text->setpositiony ( -150): text-> Setpositiony (Text->getpositiony () +2);}


Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

Cocos2d-x using Ccclippingnode to realize the marquee

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.