寻求帮助,我是 cocos2dx 的新手,并且在使用Eclipse IDE时遇到错误。
在 HelloWorld.cpp 中,我正在这样做:
_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;
}
}
}
请回复,我知道上面有很多代码,但我想知道我是否做错了什么。任何帮助或建议将不胜感激。谢谢!
问候,穆罕默德·塔希尔·阿什拉夫