案例一:
//创建文字
auto text=Label::createWithTTF("HELLO WORLD\n I LOVE YOU", "fonts/arial.ttf", 36);
text->setColor(Color3B::BLUE);
text->setAlignment(TextHAlignment::CENTER);
text->setPosition(250,100);
//绘制裁剪区域
auto area=DrawNode::create();
//该区域为长方形
Point point[4]={Point(100,100),Point(100,400),Point(600,400),Point(600,100)};
area->drawPolygon(point, 4, Color4F(0,255,255,255), 1, Color4F(0,255,255,255));
//绘制遮罩层
auto clipArea=ClippingNode::create();
//false显示模板裁剪部分(此处裁剪的部分为长方形),true显示剩余部分
clipArea->setInverted(false);
//设置模板
clipArea->setStencil(area);
//设置底板
clipArea->addChild(text);
addChild(clipArea);
//字体滚动
auto move=MoveBy::create(5.0f,Vec2(0, 500));
auto move2=CallFunc::create([=](){
text->setPosition(Vec2(250,100 ));
});
text->runAction(RepeatForever::create(Sequence::create(move,move2, NULL)));