Brief introduction:
Sprites are the most important elements in 2D games. Most of the visible elements in the game scene are directly or indirectly related to the sprite.
In Cococs2d-xz, sprites are represented by sprites, which draw a portion of a texture or all of the rectangular area on the screen.
Using an elf table (combining multiple sprites on a single texture) reduces the number of OpenGL ES draws.
Sprites can also be used to play animations, to set their colors, or to blend modes with other elements in the scene, etc.
In addition, some complex elements, such as maps, particle systems, fonts, and so on, are built on a sprite.
--------------------------------------------------------------------------------------------------
1. CCSprite.h header File Definition
Sprite is a 2d image (Http://en.wikipedia.org/wiki/Sprite_ (computer_graphics))
Class Cc_dll Sprite:public Node, public textureprotocol
2.
V3F_C4B_T2F_QUAD structure, defined in Base/cctypes.h
All modifications to the sprite drawing properties (except mixed mode)
Finally, it shows the modification of the variable quad of V3f_c4b_t2f_quad structure type.
3. How to draw the sprite
For the draw method of the sprite itself, when each frame is called, the Sprite is provided by the renderer
The Checkvisiblity method determines whether itself is within the window's visible range, and if it is not visible, does not send any drawing commands to OpenGL ES.
It not only reduces the waste of GPU computing, but also reduces the time renderer to sort rendercommand.
4.
In addition to making spriite display different content by modifying textures and setting different texture areas, you can also:
(1) Color blending: Used to specify how the current sprite blends with the "same position" color value in the color buffer
(2) Color overlay: Effect A color value on a layer or sprite
5.
Using the sprite table we can specify more vertices for the same draw to reduce the number of OpenGL ES draws.
Cocos2d-x uses Spriteframecache to load the sprite table and cache information for each sprite. 、
It stores each sprite in the sprite table as a Spriteframe object by parsing the configuration file.
Each Spriteframe object contains information about the sprite's texture, size, position in the texture, and so on.
It is important to note that Spriteframecache does not provide the ability to remove corresponding Texture2d object pairs.
6.
In 2D games, Sprite animations are divided into key-frame animations and skeletal animations.
"I understand the Cocos2d-x" sixth chapter Sprite Sprite reading notes