How could you animate SKScene's background color? I tried the UIView animation, but it is not surprising that this did not work. Is there an equivalent for this in the Sprite-Kit?
I am looking for something similar, but for the Sprite-Kit:
[UIView animateWithDuration:0.25 animations:^{ self.backgroundColor = [UIColor redColor]; }];
At the moment, when I am working on a UIView on SKView, I would like something more flexible.
I'm relatively new to the Sprite-Kit, so I apologize if this is very easy to do!
At the moment I have:
-(id) initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { _bg = [SKSpriteNode spriteNodeWithColor:[SKColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1] size:self.size]; _bg.position = CGPointMake(self.size.width/2, self.size.height/2); [self addChild:_bg]; } return self; } -(void) colorise :(UIColor*)color { [_bg runAction:[SKAction colorizeWithColor:color colorBlendFactor:_bg.colorBlendFactor duration:1]]; }
Also, after initializing SKView, I set the color of sprite bg depending on the value of NSUserDefault.
if ([[NSUserDefaults standardUserDefaults] integerForKey:@"currGameMode"] == 0) { ((bubbleAnimation2*)_bubbleEffectView.scene).bg.color = [UIColor colorWithRed:0.13 green:0.13 blue:0.13 alpha:1];} else {((bubbleAnimation2*)_bubbleEffectView.scene).bg.color = [UIColor colorWithRed:0.25 green:0.13 blue:0.13 alpha:1];}
Thanks!
source share