我正在使用SKAction中的repeatActionForever方法来更改SKShapeNode的颜色。
这是我的代码:
SKShapeNode *ship = [SKShapeNode node];
[ship setPath:CGPathCreateWithRoundedRect(CGRectMake(-15, -15, 40, 17), 6.25, 6.25, nil)];
ship.fillColor = [SKColor redColor];
ship.glowWidth = 3;
[ship runAction:[SKAction repeatActionForever:[SKAction sequence:@[
[SKAction colorizeWithColor:[SKColor blueColor] colorBlendFactor:1.0 duration:0.5],
[SKAction waitForDuration:0.3],[SKAction colorizeWithColorBlendFactor:1.0 duration:0.5],
[SKAction colorizeWithColor:[SKColor redColor] colorBlendFactor:1.0 duration:0.5],
[SKAction waitForDuration:0.3],
[SKAction colorizeWithColorBlendFactor:1.0 duration:0.5],
[SKAction waitForDuration:0.3]]]]];
return ship; //because it's a method
对我来说看起来不错,但是船没有变色。我做错了,谢谢。
最佳答案
与SKSpriteNode
相比,SKShapeNode
没有color
属性。因此,您的colorizeWithColor:
操作将无效。
看看这篇关于如何为fillColor
和strokeColor
设置动画的帖子:SKShapeNode - Animate color change
关于ios - SKAction更改SKShapeNode的颜色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22794967/