我有一系列我想玩的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];
}
答案 0 :(得分:1)
不需要分组,导致问题。
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];