Clippinglayer: clippinglayer () {} clippinglayer ::~ Clippinglayer () {} clippinglayer * clippinglayer: Create () {clippinglayer * layer = new clippinglayer (); If (layer & layer-> Init ()) {layer-> autorelease (); Return layer;} Delete layer; return NULL;} bool clippinglayer: Init () {settouchenabled (true); m_node = ccnode :: create (); ccclippingnode * clipper = ccclippingnode: Create (); clipper-> setcontentsize (ccsize (80,100); addchild (clipper, 1); clipper-> setposition (ccpointze RO); clipper-> addchild (m_node, 1); ccdrawnode * stencel = ccdrawnode: Create (); ccpoint rectangle [4]; rectangle [0] = CCP (0, 0); rectangle [1] = CCP (clipper-> getcontentsize (). width, 0); rectangle [2] = CCP (clipper-> getcontentsize (). width, clipper-> getcontentsize (). height); rectangle [3] = CCP (0, clipper-> getcontentsize (). height); cccolor4f white = {1, 1, 1, 1}; stenpencil-> drawpolygon (rectangle, 4, white, 1, white); Clipper-> setstenpencil (stenpencil); m_node-> setposition (ccpointzero); int countheight = 0; For (INT I = 0; I! = 10; ++ I) {cclabelttf * label = cclabelttf: Create ("112122", "Arial", 14); m_node-> addchild (Label, 1 ); label-> setposition (CCP (40, countheight * 20 + 10); countheight + = 1; m_vlabeld.push_back (Label);} setcontentsize (ccsize (80, countheight * 10 )); cclayercolor * colorlayer = cclayercolor: Create (ccc4 (200,100, 80,100),); addchild (colorlayer, 1); Return true;} void clippinglayer: registerwithtouchdispatcher () {ccdirector:: shareddirector ()-> gettouchdispatcher ()-> addtargeteddelegate (this, 1, false);} bool clippinglayer: cctouchbegan (cctouch * ptouch, ccevent * pevent) {m_touchbegin = ptouch-> getlocation (); Return true;} void clippinglayer: cctouchmoved (cctouch * ptouch, ccevent * pevent) {ccpoint Pos = ptouch-> getlocation (); float ymub = POS. y-m_touchbegin.y; float Endy = m_node-> getpositiony () + ymub; If (Endy <-100) {m_node-> setpositiony (-100); return ;} if (Endy> 100) {m_node-> setpositiony (100); return;} m_node-> setpositiony (Endy); m_touchbegin = Pos;} void clippinglayer :: cctouchended (cctouch * ptouch, ccevent * pevent ){}