cocos2dx 3.x ClippingNode裁剪图形

	auto clipNode = ClippingNode::create();
	clipNode->setInverted(true);
	clipNode->setAlphaThreshold(0.0f);
	this->addChild(clipNode, 100);


	auto newLayer = LayerColor::create(Color4B(0, 0, 0, 150)); //添加灰色层
	clipNode->addChild(newLayer);

	auto nSprite = Sprite::create("ccb/scale-9-demo.png");
	nSprite->setPosition(ccp(300, 200)); //娶到图形大小区域

	auto nSprite1 = Sprite::create("ccb/scale-9-demo.png");
	nSprite1->setPosition(ccp(300, 200));
	this->addChild(nSprite1); //再该位置创建图形,且高亮
	
	clipNode->setStencil(nSprite);

你可能感兴趣的:(cocos2dx 3.x ClippingNode裁剪图形)