水平无限滚动背景

时间:2016-07-11 15:21:32

标签: ios swift sprite-kit sprite

我创建了一个水平滚动的无限滚动背景。当它到达顶部时它会停止。你怎么让它继续而不是停在顶部。这是代码。

覆盖func update(currentTime:NSTimeInterval){

    background.position = CGPoint(x: background.position.x , y: background.position.y - 1)
    background2.position = CGPoint(x: background2.position.x , y: background2.position.y - 1)

    if (background.position.y < -background.size.width) {
        background.position = CGPointMake(background2.position.x + background2.size.height, background.position.y)

    }

    if (background2.position.y < -background2.size.width) {
        background2.position = CGPointMake(background.position.x + background.size.height, background2.position.y)
    }

0 个答案:

没有答案