gpt4 book ai didi

ios - SKAction 无法正常工作

转载 作者:行者123 更新时间:2023-11-29 12:39:35 25 4
gpt4 key购买 nike

我有一系列 SKActions 我想播放,但它们播放不正常。眼睛只会闭上,再也不会睁开。我不知道为什么会这样,但也许你知道!感谢您的帮助,谢谢。

-(void)blink {

SKAction *delay = [SKAction waitForDuration:3];
SKAction *blinkEye = [SKAction resizeToHeight:1 duration:.2];
SKAction *delay2 = [SKAction waitForDuration:.5];
SKAction *openEye = [SKAction resizeToHeight:3 duration:.2];

SKAction *group1 = [SKAction group:@[delay,blinkEye]];
SKAction *group2 = [SKAction group:@[delay2,openEye]];

SKAction *all = [SKAction sequence:@[group1,group2]];

SKAction *repeat = [SKAction repeatActionForever:all];

[self runAction:repeat];

}

在 MyScene.m 中

-(void)update:(CFTimeInterval)currentTime {
/* Called before each frame is rendered */
Player *player = (Player *)[self childNodeWithName:@"player"];
Player *lefteye = (Player *)[player childNodeWithName:@"leye"];
Player *righteye = (Player *)[player childNodeWithName:@"reye"];
[lefteye blink];
[righteye blink];

}

最佳答案

没有必要分组,它导致了问题。

SKAction *delay = [SKAction waitForDuration:3];
SKAction *blinkEye = [SKAction resizeToHeight:1 duration:.2];
SKAction *delay2 = [SKAction waitForDuration:.5];
SKAction *openEye = [SKAction resizeToHeight:3 duration:.2];

SKAction *all = [SKAction sequence:@[delay,blinkEye, delay2,openEye]]];

让每个帧更新都眨眼是行不通的。此函数每秒最多调用 60 次。

而是在创建眼睛对象时这样做:

SKAction *delay = [SKAction waitForDuration:3];
SKAction *blinkEye = [SKAction resizeToHeight:1 duration:.2];
SKAction *delay2 = [SKAction waitForDuration:.5];
SKAction *openEye = [SKAction resizeToHeight:3 duration:.2];

SKAction *all = [SKAction sequence:@[delay,blinkEye, delay2,openEye]]];

//create the lefteye object
lefteye = [[Eye alloc] init...];
//create the righteye object
righteye = [[Eye alloc] init...];
[lefteye repeatActionForever:all];

关于ios - SKAction 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25351706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com