我正在使用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
它看起来对我来说,但船没有改变颜色。我做错了什么,谢谢。
答案 0 :(得分:4)
与SKSpriteNode
相比,SKShapeNode
没有color
属性。因此,colorizeWithColor:
行动无法发挥作用。
请看一下这篇关于如何为fillColor
和strokeColor
设置动画的帖子:SKShapeNode - Animate color change