mirror of https://github.com/axmolengine/axmol.git
Inprove addSpriteFramesWithDictionary
- Moved initialization of image to an appropriate location, because it always called twice in SpriteFrameCache::addSpriteFramesWithFile()
This commit is contained in:
parent
4a2edc8ce8
commit
0469632cf8
|
@ -105,8 +105,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
||||||
CCASSERT(format >=0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
|
CCASSERT(format >=0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
|
||||||
|
|
||||||
auto textureFileName = Director::getInstance()->getTextureCache()->getTextureFilePath(texture);
|
auto textureFileName = Director::getInstance()->getTextureCache()->getTextureFilePath(texture);
|
||||||
auto image = new Image();
|
Image* image = nullptr;
|
||||||
image->initWithImageFile(textureFileName);
|
|
||||||
NinePatchImageParser parser;
|
NinePatchImageParser parser;
|
||||||
for (auto iter = framesDict.begin(); iter != framesDict.end(); ++iter)
|
for (auto iter = framesDict.begin(); iter != framesDict.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
@ -199,6 +198,10 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
||||||
bool flag = NinePatchImageParser::isNinePatchImage(spriteFrameName);
|
bool flag = NinePatchImageParser::isNinePatchImage(spriteFrameName);
|
||||||
if(flag)
|
if(flag)
|
||||||
{
|
{
|
||||||
|
if (image == nullptr) {
|
||||||
|
image = new Image();
|
||||||
|
image->initWithImageFile(textureFileName);
|
||||||
|
}
|
||||||
parser.setSpriteFrameInfo(image, spriteFrame->getRectInPixels(), spriteFrame->isRotated());
|
parser.setSpriteFrameInfo(image, spriteFrame->getRectInPixels(), spriteFrame->isRotated());
|
||||||
texture->addSpriteFrameCapInset(spriteFrame, parser.parseCapInset());
|
texture->addSpriteFrameCapInset(spriteFrame, parser.parseCapInset());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue