SKAction repeatAction withKey 和完成?
SKAction repeatAction withKey and completion?
我有一个 SKAction:
SKAction *myAction = [SKAction performSelector:@selector(methodA) onTarget:self];
我想在完成 50 个动作后调用方法 B 之前重复此动作 50 次。
[[self runAction:[SKAction repeatAction:myAction count:50]
withKey:@"myActionKey"]
completion:^{
[self methodB];
}];
它给我一个 bad receiver type 'void'
错误。如果我取出 withKey:@"myActionKey"
部分,错误就会消失,但我需要获取密钥,因为我可能需要在某个时候调用 removeActionForKey:@"myActionKey"
。
有什么办法解决这个问题吗?
您要执行的命令不存在,但您可以这样做:
SKAction *callMethodA = [SKAction runBlock:^{
[self methodA];
}];
SKAction *myAction = [SKAction repeatAction:callMethodA count:50];
SKAction *callMethodB = [SKAction runBlock:^{
[self methodB];
}];
SKAction *sequence = [SKAction sequence:@[myAction, callMethodB]];
[self runAction:sequence withKey:@"myKey"];
我有一个 SKAction:
SKAction *myAction = [SKAction performSelector:@selector(methodA) onTarget:self];
我想在完成 50 个动作后调用方法 B 之前重复此动作 50 次。
[[self runAction:[SKAction repeatAction:myAction count:50]
withKey:@"myActionKey"]
completion:^{
[self methodB];
}];
它给我一个 bad receiver type 'void'
错误。如果我取出 withKey:@"myActionKey"
部分,错误就会消失,但我需要获取密钥,因为我可能需要在某个时候调用 removeActionForKey:@"myActionKey"
。
有什么办法解决这个问题吗?
您要执行的命令不存在,但您可以这样做:
SKAction *callMethodA = [SKAction runBlock:^{
[self methodA];
}];
SKAction *myAction = [SKAction repeatAction:callMethodA count:50];
SKAction *callMethodB = [SKAction runBlock:^{
[self methodB];
}];
SKAction *sequence = [SKAction sequence:@[myAction, callMethodB]];
[self runAction:sequence withKey:@"myKey"];