2014-04-01 59 views
6

我使用SKAction中的repeatActionForever方法更改SKShapeNode的顏色。 這裏是我的代碼:SKAction更改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

SKSpriteNode相反,SKShapeNode沒有color屬性。所以你的colorizeWithColor:行動將無法正常工作。

看看這個職位上如何動畫fillColorstrokeColorSKShapeNode - Animate color change