表达式类型UIImage没有更多上下文是模糊的

时间:2017-09-29 19:51:49

标签: swift sprite-kit uiimage

以下代码在此行中生成此问题标题中显示的错误:for(index,image)in(backgroundImages){

有人可以建议如何消除这个错误

init!(backgroundImages:[UIImage], size:CGSize, scrollingDirection:ScrollingDirection, startingSpeed:CGFloat, speedDecreaseFactor:CGFloat) {
    self.backgrounds = []
    self.clonedBackgrounds = []
    self.speeds = []
    self.numberOfBackgrounds = (backgroundImages.count)
    self.scrollingDirection = scrollingDirection
    super.init(texture: nil, color:UIColor.clear, size: size)

    let zPos = 1.0 / CGFloat(numberOfBackgrounds)
    var currentSpeed = startingSpeed
    self.position = CGPoint(x:self.size.width/2, y:self.size.height/2)
    self.zPosition = -100

    for (index, image) in (backgroundImages) {
        let background = SKSpriteNode(texture: SKTexture(CGImage: image.CGImage), size:size)

        background.zPosition = self.zPosition - (zPos + (zPos * CGFloat(index)))
        background.position = CGPoint(x:0,y:0)
        let clonedBackground = background.copy() as! SKSpriteNode
        var clonedBackgroundX = background.position.x
        var clonedBackgroundY = background.position.y

        switch (scrollingDirection) {
        case .Right:
            clonedBackgroundX = -background.size.width
        case .Left:
            clonedBackgroundX = background.size.width
        default:
            break
        }

1 个答案:

答案 0 :(得分:4)

你可能意味着for (index, image) in backgroundImages.enumerated()

编译器无法弄清楚如何解构backgroundImages(index, image)的元素。