I have a class which inherits from CCNode. I made a CCArray to hold them all in my MainLayer class. Problem is, I can’t access my class’ methods from CCArray. How do I fix this?
// MyClass.h
#include "cocos2d.h"
class MyClass : public cocos2d::CCNode {
public:
void doSomething( );
}
// MyClass.cpp
#include "MyClass.h"
void MyClass::doSomething( ) {
CCLOG( "Method called from CCArray." );
}
//MainLayer.cpp
void MainLayer::fillArray( ) {
mMyCCArray = CCArray::create( 3 );
for ( int i = 0; i < mMyCCArray.capacity( ) {
mMyCCArray -> addObject( new MyClass( ) );
}
}
void MainLayer::doSomethingWithArray( ) {
for ( int i = 0; i < mMyCCArray.capacity( ) {
mMyCCArray -> objectAtindex( i ) -> doSomething( ); // <-- Xcode keeps telling me there is no 'doSomething( )' in that object in a CCArray
}
}
Any help?