Converting from Objective-C

Converting from Objective-C
0.0 0


Having some trouble with syntax conversion from Objective-C to C*+
I have a method in objective c that creates a Sprite definition with a CCRenderTexture inside it.
It would be called like this: _background = ;
or in C**: _background = this->spriteWithColor
Namely, I’m not sure how I’d write the same function here:
in C*+.

I’ll do another pastebin soon with the conversion I have so far and you can tell me how I’m doing.

Thanks in advance


Fairly sure this is a proper conversion, can anyone confirm this?

Thanks :slight_smile:


I think the issue here is that Objecive C uses a method inside bool Background::init() {}

and C*+ does not do methods like this. Am I correct?
If so, should I create these functions before bool Background::init{}
and then call them within bool Background::init?
By normal laws of C*+ this should work.

When trying to do this I recieve primary expression errors on this line:
CCSprite *spriteWithColor = (ccColor4F bgColor, float textureSize){


I’ve figured out alot since the last post.

I’ve moved spriteWithColor outside of init and made it it’s own function named:
cocos2d::CCSprite* Background::spriteWithColor(ccColor4F* bgColor, float textureSize) {}

in the header I attempt to declare it as:
virtual cocos2d::CCSprite* spriteWithColor(ccColor4F* bgColor, float textureSize);

but it returns the error: “error: spriteWithColor declared as a virtual function”

Why can I not declare it virtual? What should I do?


Could you paste the real code that cause the problem?