Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get user interaction events in playground with Swift

I'm trying to prototype a game with SpriteKit with Swift in a playground.

I'm having difficulties getting the user touch callbacks to work.

Here's what I am trying :

let view:SKView = SKView(frame: CGRectMake(0, 0, 320, 586))
XCPShowView("Live view", view)

class PrototypeScene: SKScene {

    override func didMoveToView(view: SKView) {
        self.userInteractionEnabled = true
    }

    override func touchesBeganWithEvent(event: NSEvent!)
    {
        println("Hello touches")   
    }
}

let scene:PrototypeScene = PrototypeScene(size: CGSizeMake(320, 586))
scene.scaleMode = SKSceneScaleMode.AspectFit

view.presentScene(scene)

I'm not getting the callbacks for the responder chain. How would one enable this?

like image 859
Tibor Udvari Avatar asked Jul 05 '14 06:07

Tibor Udvari


1 Answers

User interaction is not available in Playgrounds (Source: WWDC).

like image 128
Andy Barnard Avatar answered Sep 22 '22 23:09

Andy Barnard