首页 > 代码库 > 各种特效

各种特效

//雪花效果
schedule(schedule_selector(MainBoard::addSnowLight),0.2);

void MainBoard::addSnowLight(float dt){

    UIImageView* pSnow = UIImageView::create();
    pSnow->loadTexture("GameUI/snow.png");
    pSnow->setPosition(ccp(rand() % 800,rand() % 480));
    pSnow->setAnchorPoint(ccp(0.5,0.5));
    pSnow->setOpacity(0);
    pBackground->addChild(pSnow);

    pSnow->runAction(CCSequence::create(CCFadeIn::create(0.5),CCFadeOut::create(0.5),NULL));
    pSnow->runAction(CCSequence::create(CCMoveBy::create(1,ccp(-100,-100)),CCRemoveSelf::create(),NULL));
    pSnow->runAction(CCRotateBy::create(1,360));
}
//按钮闪烁特效
schedule(schedule_selector(MainBoard::addStartLight),2);

void MainBoard::addStartLight(float dt){

    for(int i = 0;i < 2;i++){

        UIImageView* pLight = UIImageView::create();
        pLight->loadTexture(i == 0 ? "GameUI/startLight2.png" : "GameUI/startLight.png");
        pLight->setAnchorPoint(ccp(0.5,0.5));
        pLight->setPosition(ccp(675,70));
        addChild(pLight);
        pLight->runAction(CCSequence::create(CCDelayTime::create(i * 0.05),
            CCEaseOut::create(CCScaleTo::create(0.5,1.3),5),CCScaleTo::create(0.3,1.7),CCRemoveSelf::create(),NULL));
        pLight->runAction(CCSequence::create(CCDelayTime::create(i * 0.05),
            CCEaseOut::create(CCFadeOut::create(0.7),3),NULL));
    }
}


来自为知笔记(Wiz)


各种特效