Donnerstag, 4. Mai 2017

subclassing SCNNode and add parameters to the call

class box : SCNNode {

     override init() {
        super.init()
    }
    
    init(x: Float, y: Float) {
        super.init()
        
        // grüner würfel
        let boxmesh = SCNBox(width: 1, height: 1, length:1, chamferRadius: 0 )
        let mat = SCNMaterial()
        mat.diffuse.contents = UIColor(red: 0.3, green: 0.8, blue: 0.3, alpha: 1)
        boxmesh.materials = [mat]
        self.geometry = boxmesh
        self.name = "box"
        self.castsShadow = false
        world.addChildNode(self)
        
        self.position.x = x
        self.position.y = y
    }

    /* Xcode required this */
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }


}