标签:cocos2d-x3.1 clippingnode 闪亮标题
auto clip = ClippingNode::create();//创建裁剪节点 auto gameTitle = Sprite::create("game_title.png"); clip->setStencil(gameTitle);//设置裁剪模板 clip->setAlphaThreshold(0);//设置透明度阈值 clip->setContentSize(Size(gameTitle->getContentSize().width,gameTitle->getContentSize().height));//设置裁剪节点大小 auto clipSize = clip->getContentSize();//获取裁剪节点大小 clip->setPosition(Vec2(visibleSize.width/2,visibleSize.height/2));//设置裁剪节点位置 log("clipSize.x = %lf,clipSize.y = %lf",clipSize.width,clipSize.height);//log查看一下位置,没用的 auto gameTitle_show = Sprite::create("game_title.png");//创建要显示的对象 auto spark = Sprite::create("spark.png");//创建闪亮精灵 clip->addChild(gameTitle_show,1);//把要显示的内容放在裁剪节点中,其实可以直接clip->addChild(gameTitle,1);此处为了说明更改显示内容 spark->setPosition(Vec2(-visibleSize.width/2, 0));//设置闪亮精灵位置 clip->addChild(spark,2);//添加闪亮精灵到裁剪节点 addChild(clip,4);//添加裁剪节点 auto moveAction = MoveTo::create(2.6, Vec2(clipSize.width, 0));//创建精灵节点的动作 auto moveBack = MoveTo::create(2.6, Vec2(-clipSize.width, 0)); auto seq = Sequence::create(moveAction,moveBack, NULL); auto repreatAction = RepeatForever::create(seq); spark->runAction(repreatAction);//精灵节点重复执行动作
Cocos2d-x3.1利用ClippingNode实现标题闪亮特效,布布扣,bubuko.com
Cocos2d-x3.1利用ClippingNode实现标题闪亮特效
标签:cocos2d-x3.1 clippingnode 闪亮标题
原文地址:http://blog.csdn.net/yuxikuo_1/article/details/38518677