【问题标题】:SceneData error: Type of expression is ambiguous without more contextSceneData 错误:表达式类型不明确,没有更多上下文
【发布时间】:2015-09-12 17:10:17
【问题描述】:

在带有 Swift 2 的 Xcode 7 GM 中,我在以下行中收到错误“表达式类型不明确,没有更多上下文”:var sceneData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil)!

谁能帮我解决这个问题?谢谢!

【问题讨论】:

    标签: ios xcode swift2 ios9


    【解决方案1】:

    使用 swift 2 在加载 .sks 文件时会发生一些变化,您应该创建一个全新的 SpriteKit 项目,以便您可以看到它现在是如何工作的,基本上您不必扩展 SKNode,而是使用方法:

    var sceneData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil)!
    

    你做这样的事情:

    if let scene =  GameScene(fileNamed:"GameScene") { //your code here i.e. present your scene }
    

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 2019-02-01
      • 2022-11-18
      • 2015-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多