cocos2dx clippingNode裁剪

前端之家收集整理的这篇文章主要介绍了cocos2dx clippingNode裁剪前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. /****************************************************************************/
  2. auto imgNewHead = Sprite::create("moban.png") ;
  3. //imgNewHead->setScale(0.5);
  4.  
  5. //auto bg = LayerColor::create(Color4B(255,255,255));
  6. //this->addChild(bg,-1);//1
  7. auto stencil = Sprite::create("paijiuRes/pj_touxiang2.png");
  8. auto clipperNew = ClippingNode::create();
  9. clipperNew->setStencil(stencil);//设置裁剪模板 //3
  10. clipperNew->setInverted(true);//设置底板可见
  11. clipperNew->setAlphaThreshold(0.5);//设置绘制底板的Alpha值为0
  12. auto content = Sprite::create("diban.png");//被裁剪的内容
  13. clipperNew->addChild(content);//5
  14. clipperNew->setPosition(Vec2(stencil->getContentSize().width/2 +200,stencil->getContentSize().height/2 +100));
  15. imgNewHead->setPosition(Vec2(stencil->getContentSize().width/2 +200,stencil->getContentSize().height/2 +100));
  16. userheadbg->addChild(imgNewHead);
  17. userheadbg->addChild(clipperNew);
  18. /****************************************************************************/
  19.  

猜你在找的Cocos2d-x相关文章