SKScene in SceneKit

时间:2018-02-26 17:43:08

标签: sprite-kit scenekit arkit

I am attempting to add an animated SKScene to SCNScene inside ARKit. Upon viewing WWDC 2017 session 609 this seems possible. In the presentation the code looks like this...

//Get SpriteKit scene
let spriteKitScene = SKScene(fileNamed: "SpriteKitScene")

//Create plane geometry
let plane = SCNPlane(width: 10.0, height: 10.0)

//Set SpriteKit scene on the plane's material
plane.firstMaterial?.diffuse.contents = spriteKitScene

//If material double-sided, SpriteKit scene will show up on both sides of the plane
plane.firstMaterial?.isDoubleSided = true

//Create a SceneKit node for the plane
let sceneKitNode = SCNNode(geometry: plane)

//Add the Scenekit node to the SceneKit scene
scene.rootNode.addChildNode(sceneKitNode)

Things I can do:

  • Get the SKScene loaded
  • Add sprites in sceneDidLoad() in the associated .swift file

Things I can't do:

  • Use any of the traditional methods in the SKScene's .swift file, like didMove(to) or update().
  • Add actions to nodes in the scene in sceneDidLoad()

Not sure what I am missing. The presenter in the season shows animated and interactive SK content.

1 个答案:

答案 0 :(得分:0)

想出来了。

didMove没有被调用,因为当它被添加到diffuse.contents时它不在响应者链中。

更新未被调用,因为以这种方式添加SKScene时会暂停。

相关问题