Create a Vector of Custom Sprite

Hello,

I have created a custom Sprite class and, obviously subclassed it from Sprite. I am wondering if there is a way to create a vector of my custom sprite, like Vector<CustomSprite*> customSprites;. Is there a way to do it? Currently, when I try it, it says that it is an invalid type because it does not derive from Object; however, Sprite does and I can definitely create a vector of type Sprite.

The reason I need it is because I do not want the cast to be temporary. I have private members for that sprite that I need for the game. I can cast it temporarily, but anything I update will not stay.

How should I go about it? Should I just resort to the default std::Vector<T>?

@tuxagon I still use it that way . this is my code i used to for my game .

class Item : public CCSprite { } vector <Item*> listItem ;

@xuyenit55 That may work for CCSprite, but I am using Sprite from cocos2dx 3 beta2. It should work, theoretically; however, it does not, currently. I found the answer to it recently. I was mis-remembering how subclasses are handled when the type is of the parent’s type. You can just cast the parent to the child and the data specific to the child will remain. It was a mistake on my part for forgetting that detail about inheritance. Also, std::vector<T> causes many issues in cocos2dx 3 beta2, so I was unable to use that at all.