我不完全确定您为什么要推送到视图控制器。如果您只想过渡到一个新场景,您可以在场景中执行此操作,而无需靠近父视图控制器:
YourScene *nextScene = [[YourScene alloc] initWithSize:self.size];
SKTransition *reveal = [SKTransition pushWithDirection:SKTransitionDirectionDown duration:3.0];
[self.view presentScene:nextScene transition:reveal];
如果您确实想从视图控制器调用它,您可以将视图控制器添加为场景中的属性:
#import "YourViewController.h"
@property (nonatomic,weak) YourViewController *viewController;
当您设置初始场景时,在您的视图控制器中,将视图控制器分配给该属性:
yourScene.viewController = self;
然后,您可以在场景中调用视图控制器上的方法:
[viewController yourMethod];
这是:
//YourViewController.h
#import "YourScene.h"
...
-(void)yourMethod;
//YourViewController.m
...
-(void)yourMethod
{
YourScene *nextScene = [[YourScene alloc] initWithSize:self.size];
nextScene.viewController = self;
SKTransition *reveal = [SKTransition pushWithDirection:SKTransitionDirectionDown duration:3.0];
[yourSKView presentScene:nextScene transition:doors ];
}