Transitions转场动画
SceneKit利用Sprite Kit的SKTransition对象进行过渡效果,需要导入Sprite Kit。
第一步: 定义转场动画的类型
let transition = SKTransition.doorsOpenVertical(withDuration: 1.0)
第二步: 给场景添加转场动画并执行
//scnView是创建的场景
scnView.present(splashScene, with: transition, incomingPointOfView: nil, completionHandler: {
//转场动画完成之后需要执行的内容
})
有很多过渡效果可供您使用:
从当前场景到新场景的交叉渐变。
open class func crossFade(withDuration sec: TimeInterval) -> SKTransition
当前场景首先淡入黑色,然后通过淡入淡出呈现新场景。
open class func fade(withDuration sec: TimeInterval) -> SKTransition
当前场景首先淡入一个恒定的颜色,然后通过淡入其中呈现新的场景。
open class func fade(with color: UIColor, duration sec: TimeInterval) -> SKTransition
呈现新场景,水平翻转当前场景。
open class func flipHorizontal(withDuration sec: TimeInterval) -> SKTransition
呈现新场景,垂直翻转当前场景。
open class func flipVertical(withDuration sec: TimeInterval) -> SKTransition
当前场景移出,露出新场景在它下面
open class func reveal(with direction: SKTransitionDirection, duration sec: TimeInterval) -> SKTransition
通过将其移动到当前场景的顶部来呈现新场景。
open class func moveIn(with direction: SKTransitionDirection, duration sec: TimeInterval) -> SKTransition
通过推出当前场景来呈现新场景。
open class func push(with direction: SKTransitionDirection, duration sec: TimeInterval) -> SKTransition
将新场景呈现为一对开放的水平门
open class func doorsOpenHorizontal(withDuration sec: TimeInterval) -> SKTransition
将新场景呈现为一对打开的垂直门。
open class func doorsOpenVertical(withDuration sec: TimeInterval) -> SKTransition
将新场景呈现为一对关闭的水平门。
open class func doorsCloseHorizontal(withDuration sec: TimeInterval) -> SKTransition
将新场景呈现为一对关闭的垂直门。
open class func doorsCloseVertical(withDuration sec: TimeInterval) -> SKTransition
当两扇门打开时,现场消失,从开门后面展现出新的景象。
open class func doorway(withDuration sec: TimeInterval) -> SKTransition
网友评论