How to create Sprite array for rectangle and Images

Hi ,

I’m very new in cocos2d. I want to make a simle pair game and I need array for hold that images. I tried some codes but that didnt work. Can you help me about this. And maybe there is a simple application like i told you if you pleas let me know.

Thank you.!

Are you new to C++ too? You aren’t asking a specific cocos2d-x question really.

std::vector<Sprite*> _mySprites;

cocos2d::Sprite* mySprite = cocos2d::Sprite::create("myfile.png");

_mySprites.push_back(mySprite);
1 Like

Yes I am also new to C++. But I will try that , Thank you ! :slight_smile:

Try Vector<Sprite*> with upper case V. if you use std::vector, it will not retain your sprite.

1 Like

Good point nite - if you don’t use cocos2d::Vector, you need to do a sprite->retain()