Skip to content

Instantly share code, notes, and snippets.

@takashi1975
Created December 1, 2015 05:29
Show Gist options
  • Save takashi1975/df1f995f1740aaf080e3 to your computer and use it in GitHub Desktop.
Save takashi1975/df1f995f1740aaf080e3 to your computer and use it in GitHub Desktop.
Cocos2d-x Sprite::create について
const auto fileName = "image.png";
if (auto frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(fileName))
{
if (auto sprite = Sprite::createWithSpriteFrame(frame))
{
this->addChild(sprite);
}
}
else if (FileUtils::getInstance()->isFileExist(fileName))
{
if (auto sprite = Sprite::create(fileName))
{
this->addChild(sprite);
}
}
else
{
CCLOG("Image(%s) is not Found.", fileName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment