Members Chapter Previous Next

## class CDXSpriteList

Sprite lists are used to store sprites in a dynamic fashion. A CDXSpriteList is a linked list of CDXSprite objects, which can be added and removed at run-time.

LOOPING THE LIST: When using a sprite list you will often need to loop through the list and perform operations on each of the sprites in the list, such as updating their positions. The code below shows how to loop through a CDXSpriteList:

     CDXSpriteList SpriteList;
     CDXSprite* Node;

CDXSprite* Save;

     for(Node = SpriteList.Next(); Node != SpriteList.List(); Node = Save)
     {
        Save = Node->m_Next;
        Add code to update sprite here
     }

Notice that if you intend to remove sprites from the list as you update them you must save a pointer to the next sprite in the list to prevent the loop becoming lost.

`#include "cdxsprite.h"`