Out-of-line definition of ‘getBackImage’ does not match any declaration in ‘Card’
背景分析:在vs中没有这个错误,在xcode中有可能会出现这个问题。
// CC_PROPERTY(Node*, _backImage, BackImage);
// CC_PROPERTY(Node*, _frontImage, FrontImage);
封装的get和set方法,有可能会报:
Out-of-line definition of ‘getBackImage’ does not match any declaration in ‘Card’
解决办法:
方法一:
将上面的方法改为普通的get和set方法:
// 将上面方法修改为普通方法
Node* _backImage;
void setBackImage(cocos2d::Node* var);
Node* getBackImage();
Node* _frontImage;
void setFrontImage(cocos2d::Node* var);
Node* getFrontImage();
可能需要注意的是他的作用区域,是protected还是public。
具体上面方法实现的代码参考如下:
Node* Card::getBackImage(){
return _frontImage;
}
Node* Card::getFrontImage(){
return _frontImage;
}
void Card::setFrontImage(cocos2d::Node* var){
if(nullptr =