Blink in Sprite Kit
Use SKAction, colorizeWithColor method.
Example
Implemented in SKSpriteNode
When tapping node, blink event are invoked.
CharacterNode.h
@interface CharacterNode : SKSpriteNode @end
CharacterNode.m
@implementation CharacterNode
- (instancetype)init {
if(self = [super initWithImageNamed:@"character"]){
self.userInteractionEnabled = YES; // Interaction YES, you can handle touch events
}
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self blink];
}
- (void)blink {
SKAction *blinkCyan = [SKAction sequence:@[[SKAction colorizeWithColor:[UIColor cyanColor] colorBlendFactor:1.0 duration:0.2], [SKAction waitForDuration:0.1], [SKAction colorizeWithColorBlendFactor:0.0 duration:0.2]]];
[self runAction:blinkCyan];
}
