Search code examples
cocos2d-x

what‘s the difference between CCTexture2D and CCSpriteFrame?


As we know, there are two ways to create CCSprite, using CCTexture2D and CCSpriteFrame.

what‘s the difference between CCTexture2D and CCSpriteFrame?

According to CCTexture2D API and CCSpriteFrame API, they can both be created by files.

I can not find the key point.


Solution

    • CCTexture2D is the whole texture. It contains texture info like size, OpenGL texture name, GL program etc;
    • CCSpriteFrame is part of texture. It contains CCTexture2D and a rectangle area that we would like to use from texture.

    Usually CCSpriteFrame is used with sprite atlases created with 3rd party programs (like texturepacker or zwoptex).

    P.S. I advise You to use the 3rd version of Cocos2d-x