Made
To scroll the text in a certain area, use CCClippingNode to make a cropping area. The text in this area can be displayed, and the text cannot be seen after the area is displayed.
Bool TestLayer: init () {CCSize size = CCDirector: sharedDirector ()-> getVisibleSize (); // create the text to be displayed, text = CCLabelTTF :: create ("text \ nbaibai \ n White \ nbaibai \ nhaha \ nahha \ n", "", 30); text-> setPosition (ccp (100, -120); // draw the CCDrawNode * shap = CCDrawNode: create (); CCPoint point [4] = {ccp (200), ccp (, 0 ), ccp (200,200), ccp (0,200)}; shap-> drawPolygon (point, 4, ccc4f (355,255,255,255), 2, ccc4f ( 255,255,255,255); CCClippingNode * cliper = CCClippingNode: create (); cliper-> setstencel (shap); cliper-> setAnchorPoint (ccp (. 5 ,. 5); cliper-> setPosition (ccp (100, 20); addChild (cliper ); // Add the text to be rolled to the cropping area cliper-> addChild (text); // scroll the text, and start schedule (schedule_selector (CTestLayer: rollText) after the range is exceeded )); return true;} void TestLayer: rollText (float) {text-> getPositionY ()> 300? Text-> setPositionY (-150): text-> setPositionY (text-> getPositionY () + 2 );}
: