SKSpriteNode不会使用顺序Sprite Kit中的SKAction进行fadeInWithDuration

Ste*_*fan 6 xcode sprite-kit skaction

我按顺序运行3个SKActions,前两个运行正常,但fadeInWithDuration不会在节点中淡入,当视图加载时,节点会立即添加.我是否必须将节点的初始Alpha通道设置为0?有人可以解决问题吗?

- (void)setUpButtonStart
{
    SKSpriteNode *buttonStart = [SKSpriteNode spriteNodeWithImageNamed:@"start"];
    buttonStart.name = @"buttonStart";
    buttonStart.position = CGPointMake(900,50);
    [self addChild:buttonStart];

    SKAction *wait = [SKAction waitForDuration:2.5];
    SKAction *readIntro = [SKAction playSoundFileNamed:@"intro.mp3" waitForCompletion:NO];
    SKAction *fadeIn = [SKAction fadeInWithDuration:1.0];

    SKAction *sequence = [SKAction sequence:@[wait, readIntro, fadeIn]];

    [buttonStart runAction: sequence];
}
Run Code Online (Sandbox Code Playgroud)

Bat*_*lia 18

文档中所述,该fadeInWithDuration操作alpha将节点的属性从其当前值更改为1.0(100%不透明度).

这就是为什么你没有看到淡入 - 你的动作实际上不会做任何事情,因为节点的默认alpha值是1.0,它将从100%变为100%.

正如Steffen在他的评论中所建议的那样,你需要做的就是buttonStart.alpha = 0.0在行动执行之前设定.