Macaw iOS - 动画或反向点击

问题描述 投票:1回答:1

我只是陷入了金刚鹦鹉图书馆并尝试在点击事件上做一些简单的动画。

我有一个简单的动画工作,如果你点击一个节点它动画到一个新的节点。现在当你再次点击我想要反转动画。然而,反向动画似乎并没有激发。

class button: MacawView {
  var animation:Animation?
  var reverse:Bool = false

  required convenience init?(coder aDecoder: NSCoder) {
    let stroke = Stroke(width: 15.0, cap: .round)

    let contents1 = [
        Shape(form: Line(x1: 150.0, y1: 150.0, x2: 175.0, y2: 125.0), stroke: stroke),
        Shape(form: Line(x1: 150.0, y1: 150.0, x2: 225.0, y2: 150.0), stroke: stroke),
        Shape(form: Line( x1: 150.0, y1: 150.0, x2: 175.0, y2: 175.0), stroke: stroke),
        ]

    let contents2 = [
        Shape(form: Line(x1: 130.0, y1: 110.0, x2: 245.0, y2: 110.0), stroke: stroke),
        Shape(form: Line(x1: 130.0, y1: 150.0, x2: 245.0, y2: 150.0), stroke: stroke),
        Shape(form: Line(x1: 130.0, y1: 190.0, x2: 245.0, y2: 190.0), stroke: stroke),
        ]

    let group = contents1.group()

    self.init(node: group, coder: aDecoder)
    animation = group.contentsVar.animation(to: contents2)
    group.onTap { (tapEvent) in
        if(!self.reverse) {
            self.animation?.play()
        } else {
            _ = self.animation?.reverse().play()
        }
        self.reverse = !self.reverse
    }
  }
}

我有一种感觉,因为我不太了解金刚鹦鹉团体和内容的生命周期。这或者是回调中的范围问题。当我希望它反转时再次调用回调,并进入反向线,它似乎什么也没发生。

有没有人有任何想法?

ios swift animation
1个回答
1
投票

原来在Macaw中没有ShapeAnimation的reverse()方法。这个拉动请求修复了问题https://github.com/exyte/Macaw/pull/324欢迎您查看

© www.soinside.com 2019 - 2024. All rights reserved.