From 8bc531a0fb83efad92214c86397560323a371174 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 10 Jun 2014 12:04:20 +0800 Subject: [PATCH] Fixed #5533: Fix usage of new SpriteFrame in engine --- cocos/2d/CCSpriteFrame.h | 2 +- cocos/2d/CCSpriteFrameCache.cpp | 38 +++++++++++++++------------------ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/cocos/2d/CCSpriteFrame.h b/cocos/2d/CCSpriteFrame.h index e5d3972c39..bf214ff653 100644 --- a/cocos/2d/CCSpriteFrame.h +++ b/cocos/2d/CCSpriteFrame.h @@ -114,7 +114,7 @@ public: // Overrides virtual SpriteFrame *clone() const override; -//CC_CONSTRUCTOR_ACCESS: +CC_CONSTRUCTOR_ACCESS: /** * @lua NA */ diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index 66b06f76c0..94fc0fe559 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -132,13 +132,12 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu ow = abs(ow); oh = abs(oh); // create frame - spriteFrame = new SpriteFrame(); - spriteFrame->initWithTexture(texture, - Rect(x, y, w, h), - false, - Vec2(ox, oy), - Size((float)ow, (float)oh) - ); + spriteFrame = SpriteFrame::createWithTexture(texture, + Rect(x, y, w, h), + false, + Vec2(ox, oy), + Size((float)ow, (float)oh) + ); } else if(format == 1 || format == 2) { @@ -155,13 +154,12 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu Size sourceSize = SizeFromString(frameDict["sourceSize"].asString()); // create frame - spriteFrame = new SpriteFrame(); - spriteFrame->initWithTexture(texture, - frame, - rotated, - offset, - sourceSize - ); + spriteFrame = SpriteFrame::createWithTexture(texture, + frame, + rotated, + offset, + sourceSize + ); } else if (format == 3) { @@ -186,17 +184,15 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu } // create frame - spriteFrame = new SpriteFrame(); - spriteFrame->initWithTexture(texture, - Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height), - textureRotated, - spriteOffset, - spriteSourceSize); + spriteFrame = SpriteFrame::createWithTexture(texture, + Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height), + textureRotated, + spriteOffset, + spriteSourceSize); } // add sprite frame _spriteFrames.insert(spriteFrameName, spriteFrame); - spriteFrame->release(); } }