尋找一些幫助,蔭新cocos2dx並具有使用的Eclipse IDEcocos2dx未定義參考
HelloWorld.cpp IAM內error.iam這樣:
_backgroundNode = CCParallaxNodeExtras::node();
,它給我未定義的參考錯誤,如下所示
未定義的引用'CCParallaxNodeExtras :: node()'
我CCParallaxNodeExtras.h頭文件的代碼如下它繼承CCParallaxNode
using namespace cocos2d;
#include "cocos2d.h"
class CCParallaxNodeExtras : public cocos2d::CCParallaxNode {
public :
// Need to provide a constructor
CCParallaxNodeExtras();
// just to avoid ugly later cast and also for safety
static CCParallaxNodeExtras* node();
// Facility method (it’s expected to have it soon in COCOS2DX)
void incrementOffset(CCPoint offset, CCNode* node);
};
#endif
這裏是CCParallaxNodeExtras.cpp
#include "CCParallaxNodeExtras.h"
using namespace cocos2d;
// Hack to access CCPointObject (which is not a public class)
class CCPointObject : cocos2d::CCObject {
CC_SYNTHESIZE(cocos2d::CCPoint, m_tRatio, Ratio)
CC_SYNTHESIZE(cocos2d::CCPoint, m_tOffset, Offset)
CC_SYNTHESIZE(cocos2d::CCNode *, m_pChild, Child) // weak ref
};
// Need to provide a constructor
CCParallaxNodeExtras::CCParallaxNodeExtras() {
cocos2d::CCParallaxNode(); // call parent constructor
}
CCParallaxNodeExtras* CCParallaxNodeExtras::node() {
return new CCParallaxNodeExtras::CCParallaxNode();
}
void CCParallaxNodeExtras::incrementOffset(cocos2d::CCPoint offset,CCNode *node){
for(unsigned int i = 0; i < m_pParallaxArray->num; i++) {
CCPointObject *point = (CCPointObject *)m_pParallaxArray->arr[i];
CCNode *curNode = point->getChild();
if(curNode->isEqual(node)) {
point->setOffset(ccpAdd(point->getOffset(), offset));
break;
}
}
}
請回復,我知道有很多代碼以上,但我想知道如果IAM做任何錯誤。任何幫助或suggesstion將不勝感激。謝謝!
的問候,穆罕默德 阿什拉夫塔希爾
謝謝4的答案,我試過這個,但仍然有相同的錯誤..! –