I used below cocos2d
code and worked:
CCSprite *sprite1 = [[CCSprite alloc] init];
sprite1.position = ccp(SW*0.1f, SH*0.82f);
sprite1.normalMapSpriteFrame = normalMap;
sprite1.effect = glass;
sprite1.colorRGBA = [CCColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.0f];
Now tried to port it to Swift, but getting error for colorRGBA
last line. Help me to get right code.
var sprite1 = CCSprite.node() as CCSprite
sprite1.position = ccp(SW*0.1, SH*0.82);
sprite1.normalMapSpriteFrame = normalMap;
sprite1.effect = glass;
sprite1.colorRGBA = ______ ?
Just created a new project with SpriteBuilder in Swift, tried this and all worked:
var sprite = CCSprite()
sprite.colorRGBA = CCColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
Maybe you need to look at official documentation or this answer about bridging headers? They will help you to use Objective-C classes in Swift.
I did not test this...but you can try
sprite1.colorRGBA = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With