I had checked the cocos2d-x source code and I found that CCSPrite ‘s init() method excued twice in all CCSprite’s static method.
and so on.
beacuse what they do is new a CCSprite at the begin of the method,and there is a init() method in the CCSprite Constructor.
all of these static method end with initTexture()method, and in this method there appears a init() method again.
so, init() method excuted twice.
What I want to say is that why not virtual init() method ?
if so ,we can wirte my code like this in child of CCSPrite
bool CCSpriteChild::init()and then remove the init() method in CCSprite’ constructor method
....do some init thing of child
last we can we can use a Macro to let all CCSPrite’s child implemt all CCSprite::spriteWithxxx like static method:
#define LAYER_SPRITE_WITH_SPRITE_FRAME_NAME(layer) static layer* spriteWithSpriteFrame(CCSpriteFrame pSpriteFrame) ; static layer spriteWithSpriteFrameName(const char *pszSpriteFrameName)