Ccsprite is a 2D image. ccsprite can be created through an image or a rectangular subarea in the image. If its parent node or any node on the inherited tree is ccspritebatchnode, it has the following features:
When the parent node is ccspritebatchnode, it features a higher rendering speed. In particular, ccspritebatchnode has many subnodes, but it has the following restrictions:
A. Photography functions are not supported (for example, the ccorbitcamera action cannot be executed)
B. grid-based actions are not supported (for example, cclens, ccripple, and cctwirl)
C. The alias/antialias attribute belongs to ccspritebatchnode, so you cannot set the aliase attribute separately.
D. The rendering function attribute belongs to ccspritebatchnode, so you cannot set the rendering function attribute separately.
E. Parallax scrolling is not supported, but the "proxy" genie can be used to simulate a common ccnode if its parent node is used, ccsprite has the same behavior as any other ccnode.
Despite the above restrictions, it also has the following advantages:
A. Support for the rendering (blending) Function
B. Support for Alias/antialias • But rendering speed is slow. Each time only one subnode is rendered, the default ccsprite point (0.5, 0.5)
It can be said that this can be used for all operations related to images. It mainly provides loading and displaying of images and loading sequence frames for animation playback.
Class inheritance Diagram
In addition to the ccnode inherited functions, the main functions include the following:
Virtual void settexture (cctexture2d * texture) // sets the sprite texture
Virtual cctexture2d * gettexture (void) // gets the sprite texture
Bool initwithtexture (cctexture2d * ptexture) // initialize the genie Based on the texture
Bool initwithtexture (cctexture2d * ptexture, const ccrect & rect) // initialize the genie based on the region specified by the texture
Bool initwithspriteframe (ccspriteframe * pspriteframe) // initialize the genie Based on spriteframe
Bool initwithspriteframename (const char * pszspriteframename) // initialize the genie Based on the spriteframe name
Bool initwithfile (const char * pszfilename) // initialize the genie Based on the plist File
Bool initwithfile (const char * pszfilename, const ccrect & rect) // initialize the genie Based on the plist File
Bool initwithbatchnode (ccspritebatchnode * batchnode, const ccrect & rect) // batch initialize the genie Based on the node
Void setdisplayframewithanimationname (const char * animationname, int frameindex)
Static ccsprite * spritewithtexture (cctexture2d * ptexture) // generate genie Based on Texture
Static ccsprite * spritewithtexture (cctexture2d * ptexture, const ccrect & rect) // generate genie based on the region specified by the texture
Static ccsprite * spritewithtexture (cctexture2d * ptexture, const ccrect & rect, const ccpoint & offset) // generates an genie based on the region and point offset specified by the texture
Static ccsprite * spritewithspriteframe (ccspriteframe * pspriteframe) // generate genie Based on spriteframe
Static ccsprite * spritewithspriteframename (const char * pszspriteframename) // generate an genie Based on the spriteframe name
Static ccsprite * spritewithfile (const char * pszfilename) // generate ccsprite Based on plist File
Static ccsprite * spritewithfile (const char * pszfilename, const ccrect & rect) // generate genie Based on plist File
Static ccsprite * spritewithbatchnode (ccspritebatchnode * batchnode, const ccrect & rect) // generate batch genie Based on nodes