我得到了移動的背景圖片,但沒有重複。經過背景後,它會回到灰色背景。我如何讓背景永遠重複。這是迄今爲止的代碼。這是圖像:http://i.imgur.com/OgdWXJG.png Im在xcode中使用swift。謝謝。如何讓我的背景圖像永久循環?
override func didMoveToView(view: SKView) {
// Background
background = SKSpriteNode(imageNamed: "background")
background.position = CGPointMake(self.size.width/2, self.size.height/2)
self.addChild(background)
// loop Background Image
doAction1()
}
//loop background image
func loopBackground() {
let moveToBottom = SKAction.moveByX(0, y: 5000 - self.frame.size.height -
background.size.height, duration: 100.0)
let removeTheNode = SKAction.removeFromParent()
let moveAndRemoveBackground = SKAction.sequence([moveToBottom, removeTheNode])
background.runAction(moveAndRemoveBackground)
}
//background repeat action
func doAction1() {
let generateBackground = SKAction.sequence([
SKAction.runBlock(self.loopBackground),
SKAction.waitForDuration(1)])
let endlessAction1 = SKAction.repeatActionForever(generateBackground)
runAction(endlessAction1)
}