Closed
Description
For some reason touch events don't work from the first time. And after animation they don't work at all. Here is full example:
class MorphingView: MacawView {
required init?(coder aDecoder: NSCoder) {
super.init(node: MorphingView.newScene(), coder: aDecoder)
}
class func newScene() -> Node {
let stroke = Stroke(width: 15.0, cap: .round)
let contents1 = [
Shape(form: Line(x1: 90.0, y1: 110.0, x2: 210.0, y2: 110.0), stroke: stroke),
Shape(form: Line(x1: 90.0, y1: 150.0, x2: 210.0, y2: 150.0), stroke: stroke),
Shape(form: Line(x1: 90.0, y1: 190.0, x2: 210.0, y2: 190.0), stroke: stroke),
]
let contents2 = [
Shape(form: Line(x1: 110.0, y1: 150.0, x2: 135.0, y2: 125.0), stroke: stroke),
Shape(form: Line(x1: 110.0, y1: 150.0, x2: 190.0, y2: 150.0), stroke: stroke),
Shape(form: Line( x1: 110.0, y1: 150.0, x2: 135.0, y2: 175.0), stroke: stroke),
]
var switched = false
let group = contents1.group()
group.onTouchPressed { e in
group.contentsVar.animate(to: switched ? contents1 : contents2)
switched = !switched
}
return group
}
}