CCSprite* sp = CCSprite::create("Default.png"); sp->setPosition(ccp(240, 160)); addChild(sp); //常见的22种特效 //3D晃动的特效 // CCActionInterval* shaky3D = CCShaky3D::create(5, CCSize(10, 10), 15, false); // sp->runAction(shaky3D); //3D瓷砖晃动特效 // CCActionInterval* shakyTiles3D = CCShakyTiles3D::create(5, CCSize(10, 10), 5, false); // sp->runAction(shakyTiles3D); //波动特效 // CCActionInterval* waves = CCWaves::create(5, CCSize(10, 10), 10, 20, true, true); // sp->runAction(waves); //3D波动特效 // CCActionInterval* waves3D = CCWaves3D::create(5, CCSize(10, 10), 10, 20); // sp->runAction(waves3D); //3D瓷砖波动特效 // CCActionInterval* wavesTiles3D = CCWavesTiles3D::create(5, CCSize(10, 10), 10, 20); // sp->runAction(wavesTiles3D); //X轴 3D反转特效 // CCActionInterval* filpX = CCFlipX3D::create(5); // sp->runAction(filpX); //Y轴3D反转特效 // CCActionInterval* filpY = CCFlipY3D::create(5); // sp->runAction(filpY); //凸透镜特效 // CCActionInterval* lens = CCLens3D::create(2, CCSize(10, 10),CCPointMake(240, 160), 240); // sp->runAction(lens); //水波纹特效 // CCActionInterval* ripple = CCRipple3D::create(5, CCSize(10, 10), CCPointMake(240, 160), 240, 4, 160); // sp->runAction(ripple); //液体特效 // CCActionInterval* liquid = CCLiquid::create(5, CCSize(10, 10), 4, 20); // sp->runAction(liquid); //扭曲旋转特效 // CCActionInterval* twirl = CCTwirl::create(50, CCSize(10, 10), CCPointMake(240, 160), 2, 2.5); // sp->runAction(twirl); //破碎的3D瓷砖特效 // CCActionInterval* shatteredTiles = CCShatteredTiles3D::create(15, CCSize(10, 10), 50, true); // sp->runAction(shatteredTiles); //瓷砖洗牌特效 // CCActionInterval* shuffle = CCShuffleTiles::create(5, CCSize(50, 50), 50); // sp->runAction(shuffle); //部落格效果,从左下角到右上角 // CCActionInterval* fadeOutTRTiles = CCFadeOutTRTiles::create(5, CCSize(50, 50)); // sp->runAction(fadeOutTRTiles); //部落格效果,从右上角到左下角 // CCActionInterval* fadeOutBLTiles = CCFadeOutBLTiles::create(5, CCSize(50, 50)); // sp->runAction(fadeOutBLTiles); //折叠效果 从下到上 // CCActionInterval* fadeOutUpTiles = CCFadeOutUpTiles::create(5, CCSize(10, 10)); // sp->runAction(fadeOutUpTiles); //折叠效果,从上到下 // CCActionInterval* fadeOutDownTiles = CCFadeOutDownTiles::create(4, CCSize(20, 50)); // sp->runAction(fadeOutDownTiles); //方块消失特效 // CCActionInterval* turnOffFiels = CCTurnOffTiles::create(4, CCSize(50, 50)); // sp->runAction(turnOffFiels); //跳动的方块特效 // CCActionInterval* jumpTiles = CCJumpTiles3D::create(5, CCSize(20, 20), 5, 20); // sp->runAction(jumpTiles); //分多行消失特效 // CCActionInterval* splitCols = CCSplitCols::create(5, 50); // sp->runAction(splitCols); //分多列消失特效 // CCActionInterval* splitRows = CCSplitRows::create(5, 50); // sp->runAction(splitRows); //3D翻页特效 CCActionInterval* pageTurn3D = CCPageTurn3D::create(4, CCSize(20, 20)); sp->runAction(pageTurn3D); //这个是光晕效果的参数 CCSpriteBatchNode *m_Batchnode=CCSpriteBatchNode::create("bullet.png");ccBlendFunc cb={GL_SRC_ALPHA,GL_ONE}; //将光晕效果加入 m_Batchnode->setBlendFunc(cb); //最后实例化一个 CCSpriteBatchNode里this->addChild(m_Batchnode); //缓存中取出W1.png图片,这个图片是在plist文件中所在的<key>标签里面的 CCSpriteCCSprite *bullet=CCSprite::createWithSpriteFrameName("W1.png"); //记得不是用this->addChild而是用m_Batchnode->addChild(bullet); //这样就能有光晕效果啦 主要是理解CCSpriteBatchNode bullet->setPosition(ccp(x,y)); m_Batchnode->addChild(bullet); //1. 不断旋转 CCRotateBy* rotate = CCRotateBy::actionWithDuration(1, 360); CCRepeatForever* repeatRotate = CCRepeatForever::actionWithAction(rotate); //2. 上升消失 CCMoveBy* move = CCMoveBy::actionWithDuration(2, ccp(0,200)); CCFadeOut* fadeOut = CCFadeOut::actionWithDuration(2); CCFiniteTimeAction* fadeOutAct = CCSpawn::actions(move,fadeOut,NULL); //3.贝赛而曲线 ccBezierConfig bezier; bezier.controlPoint_1 = ccp(100,200); bezier.controlPoint_2 = ccp(200, -100); bezier.endPosition = ccp(400, 100); CCBezierBy* bezierBy = CCBezierBy::actionWithDuration(5.0, bezier); //4. 变色 CCTintTo* tint1 = CCTintTo::actionWithDuration(1.5, 255, 0, 0); CCTintTo* tint2 = CCTintTo::actionWithDuration(1.5, 0, 255, 255); CCTintTo* tint3 = CCTintTo::actionWithDuration(1.5, 0, 255, 0); CCFiniteTimeAction* tintActions = CCSequence::actions(tint1,tint2,tint3,NULL); CCRepeatForever* repeatTint = CCRepeatForever::actionWithAction((CCActionInterval*)tintActions); //5.闪烁 CCBlink* blink = CCBlink::actionWithDuration(5, 25); //6.动作(动画)结束后,调用某函数 CCFadeOut* fadeOut = CCFadeOut::actionWithDuration(0.8); CCCallFunc* endCall = CCCallFunc::actionWithTarget(starSprite, callfunc_selector(FlashingMeteors::removeFromParentAndCleanup)); CCFiniteTimeAction* acts = CCSequence::actions(fadeOut,endCall, NULL); starSprite->runAction(acts);