I want to make an animation in SceneKit in which the sphere is moving. I have the following code in Atoms.swift:
import Foundation
import SceneKit
class Atoms {
class func carbonAtom()->SCNGeometry {
var rootNode: SCNNode
let carbonAtom = SCNSphere(radius: 1.70)
carbonAtom.firstMaterial!.diffuse.contents = UIColor.darkGrayColor()
carbonAtom.firstMaterial!.specular.contents = UIColor.whiteColor()
let carbonNode = SCNNode(geometry: carbonAtom)
self.rootNode.addChildNode(carbonNode)//error
let moveUp = SCNAction.moveByX(0.0, y: 1.0, z: 0.0, duration: 1.0)
carbonNode.runAction(moveUp)
return carbonAtom
}
}
The error in the line starting with self is:
'Atoms.Type' does not have a member named 'rootNode'. What does this mean and what do I have to do to make the sphere move?
On Jan 12, 2015, at 10:35 AM, Bjorn Chin Fo Sieeuw <bchinf...@gmail.com> wrote:
'Atoms.Type' does not have a member named 'rootNode'. What does this mean and what do I have to do to make the sphere move?
var rootNode: SCNNode = SCNNode()
as a local variable, and it compiles. But the sphere does not move. I am trying to modify the code found here:
https://www.dropbox.com/sh/nt0hnw1tib0ppkh/AAAJMAkUQcck2F-r3VUKDd7Xa?dl=0
var rootNode: SCNNode = SCNNode()
as a local variable, and it compiles. But the sphere does not move. I am trying to modify the code found here:
https://www.dropbox.com/sh/nt0hnw1tib0ppkh/AAAJMAkUQcck2F-r3VUKDd7Xa?dl=0
I want to make an animation in SceneKit in which the sphere is moving. I have the following code in Atoms.swift: