我试图在我的主菜单中实现一个动画开始按钮。因为我的场景需要一段时间才能加载,所以我想用那个按钮动画来缩短等待时间。不幸的是动画没有开始。我的代码有什么问题?
-(void)buttonAnimation{
SKAction *HUDzoom = [SKAction scaleTo:3 duration:1];
SKAction *HUDzoomOut = [SKAction scaleTo:1.0 duration:1];
SKAction *HUDAnimation = [SKAction sequence:@[HUDzoom, HUDzoomOut]];
[self.startButton runAction:[SKAction repeatActionForever:HUDAnimation]];
}
-(void)loadScene{
SKScene *restart = [[Level_1 alloc] initWithSize:self.size];
[self.view presentScene:restart];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
if ([node.name isEqualToString:@"startLevel1"]){
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
[self loadScene];
dispatch_async(dispatch_get_main_queue(), ^{
[self buttonAnimation];
});
});
}
}