7

我正在使用 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

它看起来对我来说是正确的,但船不会改变颜色。我做错了什么,谢谢。

4

1 回答 1

6

与 a 相比SKSpriteNode, aSKShapeNode没有color属性。所以你的colorizeWithColor:动作是行不通的。

看看这篇关于如何为fillColorand设置动画的帖子strokeColorSKShapeNode - 动画颜色变化

于 2014-04-01T20:22:54.097 回答