Skip to content

Conversation

WanderWang
Copy link

reduce cc.rect() function call in ctor() to optimize performance because of cc.SpriteFrame.initWithTexture() will call the function duplicately

@dingpinglv
Copy link
Contributor

Hi Ze,

I agree with your refactoring, but I think you should add a condition to setRectInPixels and setRect of CCSpriteFrame. It will throw an error when some developers write codes like this:

var aSpriteFrame = new cc.SpriteFrame();
aSpriteFrame.setRect(cc.rect(10,10,20,20)); // it throws an error.

Although, almost of all developers like to call cc.SpriteFrame.create() to create a cc.SpriteFrame object, but we should add some conditions to avoid errors.

Thanks for your refactoring.
David

dingpinglv added a commit that referenced this pull request Dec 27, 2013
Optimize CCSpriteFrame's init performance
@dingpinglv dingpinglv merged commit 2cdc24c into cocos2d:develop Dec 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants