【发布时间】:2015-01-24 18:01:46
【问题描述】:
我有这两张图片是同一张图片,我希望它们重复,这样背景看起来就在移动。我有这段代码,但只有一个背景图像通过,然后它又回到灰屏。另一个背景图像不跟随第一个。我该如何解决?谢谢! (这是在 swift xcode 中)
func spawnBackground() {
let cloud = SKSpriteNode(imageNamed: "CloudBg")
let cloud2 = SKSpriteNode(imageNamed: "CloudBg2")
cloud.position = CGPointMake(frame.size.width + cloud.frame.size.width / 2,cloud.frame.height / 2)
cloud.setScale(1.35)
cloud.zPosition = -15
cloud2.position = CGPointMake(self.size.width/2, self.size.height/2)
cloud2.setScale(1.35)
cloud.zPosition = -15
let moveTop = SKAction.moveByX(0, y: cloud.size.height, duration: NSTimeInterval(CGFloat(gameSpeed) * cloud.size.height))
cloud.runAction(SKAction.repeatActionForever(moveTop))
cloud2.runAction(SKAction.repeatActionForever(moveTop))
addChild(cloud)
addChild(cloud2)
}
【问题讨论】: