//这个是要显示的图片
auto gameBgShow = Sprite::create("wfmc bg.png");
addChild(gameBgShow);
gameBgShow->setPosition(Vec2(visibleSize.width / 2 - 200, visibleSize.height / 2));//设置裁剪节点位置
//扫光效果
Node *pAddTo = gameBgShow ;//插入到显示的图片上
auto gameTitle = Sprite::create("wfmc bg.png");
clip->setStencil(gameTitle);//设置裁剪模板
clip->setAlphaThreshold(0);//设置透明度阈值
clip->setContentSize(Size(gameTitle->getContentSize().width, gameTitle->getContentSize().height));//设置裁剪节点大小
auto clipSize = clip->getContentSize();//获取裁剪节点大小
clip->setPosition(Vec2(gameTitle->getContentSize().width/2, gameTitle->getContentSize().height/2));//设置裁剪节点位置
log("clipSize.x = %lf,clipSize.y = %lf", clipSize.width, clipSize.height);//log查看一下位置,没用的
auto spark = Sprite::create("guang.png");//创建闪亮精灵
spark->setPosition(Vec2(-clipSize.width / 2, 0));//设置闪亮精灵位置
clip->addChild(spark, 2);//添加闪亮精灵到裁剪节点
pAddTo->addChild(clip, 4);//添加裁剪节点
auto moveAction = MoveTo::create(1.1, Vec2(clipSize.width, 0));//创建精灵节点的动作
auto moveBack = MoveTo::create(0.0, Vec2(-clipSize.width, 0));
auto delay = DelayTime::create(2.0f);
auto seq = Sequence::create(moveAction, moveBack, delay, NULL);
auto repreatAction = RepeatForever::create(seq);
spark->runAction(repreatAction);//精灵节点重复执行动作
}