[coco2d-x3.0beta2] Can cocos2d::Vector use with any data/class?

[coco2d-x3.0beta2] Can cocos2d::Vector use with any data/class?
0.0 0


When i use it with Sprite everything is ok. (ex: Vector<Sprite*> mySprites; …).

But when i use it with my own class (and it inherits cocos2d::Sprite class, ex: Vector<MyNewSprite*> mySprites) it raise an error when compile: error C2338: Invalid Type for cocos2d::Vector!

Furthermore, when i use it with cocos2d::Point (Vector myPoints), the same error happens.
Is it a bug or limitation of this data structure?


Oops, pls check my question


this problems may be a framework bug, need attention here


it works with cocos2d::Object and it’s derived classes


read here:http://www.cocos2d-x.org/docs/manual/framework/native/data-structure/v3/vector/zh


this must be fixed, i use with my own class and it not work -_-. my class inherits from cocos2d::Sprite


Take care that you implement the static create-function for your own classes. For example this class works for cocos2d::Vector

class MySprite : public cocos2d::Sprite

	static MySprite* MySprite::create(const char* name)
		MySprite* spr = new MySprite();
		if (spr->initWithFile(name))
			// your own stuff
			return spr;


And then it’s totally ok to do:

auto mysprite = MySprite::create("HelloWorld.png");
cocos2d::Vector<MySprite*> mspVec;

Reason why you need to implement the create method is, that you create vectors of your derived class type, but the default create method returns parent class type, which is not convertible to your derived class type.