簡體   English   中英

SKAction更改SKShapeNode的顏色

[英]SKAction change the color of a SKShapeNode

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

它看起來對我來說,但船不改變顏色。 我做錯了什么,謝謝。

SKSpriteNodeSKShapeNode沒有color屬性。 所以你的colorizeWithColor:動作將不起作用。

看一下這篇關於如何為fillColorstrokeColor設置動畫的strokeColorSKShapeNode - Animate顏色變化

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM