解決CCShaky3D動作後精靈紋理變形問題




方法:在3d動作後,刪除該精靈,創建一個新的精靈


.h--------------------        void newSprite(float dt);

.cpp----------------CCActionInterval *shaky=CCShaky3D::create(2, CCSizeMake(4,4),4, 0);

        pSprite->runAction(CCSequence::create(shaky,shaky->reverse(),NULL));

    this->addChild(pSprite, 0, 100);

        this->schedule(schedule_selector(HelloWorld::newSprite),2);
       


void HelloWorld::newSprite(float dt){

        this->removeChildByTag(100);

        CCSprite *newSprite = CCSprite::create("HelloWorld.png");

        this->addChild(newSprite,0);
       
        newSprite->setPosition(ccp(visibleSize.width/2 , visibleSize.height/2 ));

        this->unschedule(schedule_selector(HelloWorld::newSprite));

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章