I want to create a an array of points (_grid). However, I can't seem to use this CCPointArray anywhere except the function it's created in. I've tried making it public in my class and declaring it in my header, but all fail. Any tips?
after
CCPointArray* p = CCPointArray::create(8);
did you call
p->retain();
?
and remember to release it in your destructor or onExit();
in your YOUR_CLASS.h file
class YOUR_CLASS : public cocos2d::CCLayer {
CCPointArray* p;
public:
CREATE_FUNC(YOUR_CLASS);
bool init();
void onExit();
}
in your YOUR_CLASS.cpp file
bool YOUR_CLASS::init(){
if(CCLayer::init()){
p = CCPointArray::create(8);
p->retain();
return true;
}
return false;
}
void YOUR_CLASS::onExit(){
CCLayer::onExit();
p->release();
p = NULL;
}