Skip to content

Instantly share code, notes, and snippets.

@jiyuujin
Last active July 25, 2016 08:35
Show Gist options
  • Save jiyuujin/25df44a24dd4f19fffd6 to your computer and use it in GitHub Desktop.
Save jiyuujin/25df44a24dd4f19fffd6 to your computer and use it in GitHub Desktop.
背景クロスフェード(0.2sec)
void MenuState_PlayPerformance::playCharacter() {
replaceImage( (Sprite*)mScene->getContentsSprite()->getChildByName("background"), "bg2.png" );
}
void MenuState_PlayPerformance::replaceImage(cocos2d::Sprite* sprite, const char* imageFileName) {
sprite->setTexture( Director::getInstance()->getTextureCache()->addImage( imageFileName ) );
Texture2D *tex = Director::getInstance()->getTextureCache()->addImage( imageFileName );
sprite->setTexture( tex );
Size contentSize = tex->getContentSize();
sprite->setTextureRect( Rect(0, 0, contentSize.width, contentSize.height) );
sprite->runAction( FadeIn::create(0.2f) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment