首先要解决第二个问题,这取决于您。如果您愿意,您可以继续遵循Objective-C的约定,即每个文件只有一个类,尽管这不是必需的,并且在Objective-
C中也没有。话虽这么说,如果您有几个紧密相关的类,但是它们不是由很多代码组成,那么将它们组合在一个文件中并不是没有道理的。只要做对的事情,就不要在单个文件中编写大量的代码。
然后是第一个问题…是的,您已经掌握了很多。基本上,从您起步的地方,您需要通过其大小创建一个GameScene实例:初始值设定项。从那里,您只需设置属性并调用present。
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { super.touchesBegan(touches, withEvent: event) guard let location = touches.first?.locationInNode(self), let scene = scene, nodeAtPoint(location) == "Game Button" else { return } let transition = SKTransition.reveal( with: .down, duration: 1.0 ) let nextScene = GameScene(size: scene.size) nextScene.scaleMode = .aspectFill scene.view?.presentScene(nextScene, transition: transition)}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)