【发布时间】:2016-10-14 18:20:51
【问题描述】:
如何创建以匀速向右移动/滚动可见图像部分的动画?或者更确切地说:如何向右动画 UIScrollView?
示例:图像宽度为 4968 像素。该图像用作全屏背景图像。开始时应该只能看到 4968px(图像宽度)的前 1242px。可见图像部分应以匀速向右移动。在任何时候,1242px 的图像都是可见的。当图像结束时,应该迭代这个过程。
到目前为止,这是我的代码。理解我想要完成的事情并没有什么用,因为它不完整,但是您看到我在函数更新等中使用了它。
override func update(_ currentTime: TimeInterval) {
if gameStarted == true {
enumerateChildNodes(withName: "background", using: ({
(node, error) in
let bg = node as! SKSpriteNode
bg.position = CGPoint(x: bg.position.x - 2, y: bg.position.y)
}
}))
}
}
【问题讨论】:
标签: swift uiviewcontroller uiscrollview uiimageview