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: http://pastebin.com/wKHbKjDu
in C*+.
I’ll do another pastebin soon with the conversion I have so far and you can tell me how I’m doing.
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 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?