加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – SKAction改变SKShapeNode的颜色

发布时间:2020-12-14 19:44:31 所属栏目:百科 来源:网络整理
导读:我正在使用SKAction中的repeatActionForever方法来更改SKShapeNode的颜色. 这是我的代码: SKShapeNode *ship = [SKShapeNode node];[ship setPath:CGPathCreateWithRoundedRect(CGRectMake(-15,-15,40,17),6.25,nil)];ship.fillColor = [SKColor redColor];
我正在使用SKAction中的repeatActionForever方法来更改SKShapeNode的颜色.
这是我的代码:

SKShapeNode *ship = [SKShapeNode node];
[ship setPath:CGPathCreateWithRoundedRect(CGRectMake(-15,-15,40,17),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]]]]];
return ship; //because it's a method

它看起来对我来说,但船不改变颜色.我做错了什么,谢谢.

解决方法

与SKSpriteNode相比,SKShapeNode没有颜色属性.所以你的colorizeWithColor:动作将不起作用.

看一下这篇关于如何为fillColor和strokeColor设置动画的文章:SKShapeNode – Animate color change

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读