【新人求助】cocos 2d-x中clippingNode的一个小问题
在一个小游戏的大厅中,我想把玩家的头像显示在左上角,不过我希望是圆形的。所以找了一个圆形的素材,以此作为遮罩的模版,可是写好后发现头像只是闪了一下就消失了。
代码如下:
test_border = rootNode->getChildByName<Sprite*>("avatarBg_2"); //获取头像框,用于显示位置用
Sprite* test_stencil = Sprite::create("PlatFormRes/image/lobby/a_touxiang.png"); //模版,取其形状
test_clippingNode = ClippingNode::create(test_stencil); //创建遮罩节点
test_clippingNode->setPosition(test_border->getPosition());
test_clippingNode->addChild(m_pImgFigure, 2); //使用头像作为底板
test_clippingNode->setAlphaThreshold(0.05);
test_clippingNode->setInverted(true); //显示底板
test_clippingNode->setScale(0.8);
addChild(test_clippingNode);