Freitag, 30. Juni 2017

IAP with SWIFT

// ------------------------------ PAYMENT CLUSTERF*  ---------------
// HOW TO IMPLEMENT 
    
1. Create and configure products in iTunes Connect.
You can change your products throughout the process, but you need at least
one product configured before you can test any code.
    
2. Get a list of product identifiers, either from the app bundle or your own server. Send that list to the App Store using an instance of SKProductsRequest.
    
3. Implement a user interface for your app’s store, using the instances of SKProduct returned by the App Store. Start with a simple interface during development, such as a table view or a few buttons.
    
4. Implement a final user interface for your app’s store at whatever point makes sense in your development process.
    
5. Request payment by adding an instance of SKPayment to the transaction queue using the addPayment: method of SKPaymentQueue.
    
6. Implement a transaction queue observer, starting with the paymentQueue:updatedTransactions: method.
    
7. Implement the other methods in the SKPaymentTransactionObserver protocol at whatever point makes sense in your development process.
    
8. Deliver the purchased product by making a persistent record of the purchase for future launches, downloading any associated content, and finally calling the finishTransaction: method of SKPaymentQueue.
    
9. During development, you can implement a trivial version of this code at 
first—for example, simply displaying “Product Delivered” on the screen—and 
then implement the real version at whatever point makes sense in your development process.
    
    
// HOW TO TEST

Montag, 19. Juni 2017

identify clicks on 2d overlay

// Sehr  einfach: so filtern wir auch Buttonklicks auf 2D Elemente raus
            let location2d = touch.location(in: overlayScene)
            let hitResult2d = overlayScene.atPoint(location2d)
            if let nname = hitResult2d.name {
                print(nname)

            }

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")
    }


}

Dienstag, 6. Dezember 2016

Animate / Fade Intensity

let animation2 = CAKeyframeAnimation()
animation2.keyPath = "geometry.firstMaterial.diffuse.intensity"
animation2.values   =  [2, 0.2, 0.1, 0]
animation2.keyTimes =  [0, 0.5, 0.9, 3]
animation2.duration =  3
animation2.isAdditive = false

self.addAnimation(animation2, forKey: "test2")

Variable im Printtext


Jedesmal muss ich nachgucken. Deshalb schreibe ichs mir hier nieder:

print("Variable: \(variable)")

Mittwoch, 30. November 2016

Scenekit Call Action Every Frame

// ----------------------------
// PER FRAME CODE HERE
// ----------------------------
func renderer(_ aRenderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
        // per-frame code here 
        
}


--- snip ---

// Diese zwei Zeilen sind notwendig um einen Handler 
// für jedes Frame zu bekommen
// Ohne playing updated er offensichtlich das Bild nur bei Änderungen...
// Diese Methode geht übrigens voll auf die CPU und die Batterie !!
// und kann gar nicht wirklich empfohlen werden...

scnView.delegate  = self

scnView.isPlaying = true


--- snip ---


SWIFT / SCENEKIT: A SCNNODE removes itself after

// ------------------------------------------------------------------------
// Die SCNNODE entfernt sich nach Zeit selber aus dem Scenegraph
// Ich hoffe SWIFT´s  removeFromParentNode() räumt selber vernünftig auf...
// ------------------------------------------------------------------------
let waitaction   = SCNAction.wait(duration: TimeInterval(<lifetime>))
let removeaction = SCNAction.removeFromParentNode()
let sequence     = SCNAction.sequence([waitaction, removeaction])

<SCNNODE>.runAction(sequence)