Eclipse and inheritance - setOpacity(GLubyte)

Eclipse and inheritance - setOpacity(GLubyte)
0.0 0


Hi everyone !

I have a problem with Eclipse and the famous “The type ‘Foo’ must implement the inherited pure virtual method ‘cocos2d::CCRGBAProtocol::setOpacity’” error.

So here is the context :

I am using CCBlade for the cool ninja effect when touching the screen.
On mac and xcode, no problem. (Used by my collegue).
On windows and eclipse, err => CCBlade must implement the inherited pure virtual method ‘cocos2d::CCRGBAProtocol::setOpacity’.

The funny thing here, is that CCBlade DOES implement the method !
In header file :
CC_PROPERTY(GLubyte, _opacity, Opacity)
In cpp :
void CCBlade::setOpacity(GLubyte opacity) { _opacity = opacity; }

The CC_PROPERTY, as I understand it, creates the variable and get/set method.

So, what am I doing wrong ?
Because of this error, I can’t run the application :’(

Thanks for reading, and many thanks for helping!


Is CCBlade new? my version does not contain it.
Or did you write it?

How is the function setOpacity defined in the .h file?

Is it:-
virtual void setOpacity(


Hi, thanks for answering! :slight_smile:

CCBlade is not included with cocos2dx, you can find it here :

In the header file, the setOpacity is defined with the following line :
CC_PROPERTY(GLubyte, _opacity, Opacity);

CC_PROPERTY is a macro, and its definition is :
#define CC_PROPERTY(varType, varName, funName)\ protected: varType varName;\ public: virtual varType get##funName(void);\ public: virtual void set##funName(varType var);

So, used with the opacity, it creates the following :
protected: GLubyte _opacity; public: virtual GLubyte getOpacity(void); public: virtual void setOpacity(GLubyte var);

So that’s for the header file.
In the cpp file, we can find the following methods :
`GLubyte CCBlade::getOpacity() {
return _opacity;

void CCBlade::setOpacity(GLubyte opacity) {
_opacity = opacity;

that respond to the header declaration.
With the macro, Eclipse understands the override getter but not the setter.
Trying to remove the macro and create getter and setter in the usual way does not change anything.

Finally, even if it does not lead to any errors, Eclipse does not understand “GLubyte
When calling blade.setOpacity() Eclipse shows the following “intelissense” setOpacity(? var)

So it might come from there… I have no idea.


Sorry I was not aware of the CC_PROPERTY macro.

setOpacity(? var) - Thats likely to be the problem.
I have seen the same behaviour with some objects when I forgot to included the required header file.
The IDE suggected it was all good but the build would fail.

As setOpacity(? var) does not match setOpacity(GLubyte var) that would explain the error.
But why does ? getOpacity(void) work when it does not match GLubyte getOpacity(void)?


Well, CCBlade.cpp includes CCBlade.h and everything works just fine when I hide the error…

But it’s kind of boring to do that, and I’d like to know why it doesn’t work :-/

And yes, it’s entirely strange to see that there’s no warning for the getter. Perhaps Eclipse shows the first error only…

So my guess was to find where the GLubyte is defined, and include the specified file.
For that, I checked the included files in the CCBlade.h, to see which one defined it, but I didn’t find it…

I don’t understand any of this…


I didn’t mean its own header but something like not including coco2d.h when using CCObject in my own class.

I know loads of the base cocos2dx files use that type so its working in some places.

There is only 1 place in my own code that uses a GLubyte and the only likely include in that header is “cocos2d.h”


CCBlade.h includes cocos2d.h so it should work… (And again, it actually DOES work, but Eclipse is nuts

I suppose I’ll just continue hiding the errors in Eclipse and be on my way.

I’ll keep an eye if I find something.
Thanks for your help :wink: