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