Error in for loop CGFloat

前端 未结 1 342
我寻月下人不归
我寻月下人不归 2020-12-22 09:07

I converted a project from Swift 2 to Swift 3 and now I get an error in the following line:

for i:CGFloat in 0 ..< 2.0 + self.frame.size.width / ( skyText         


        
相关标签:
1条回答
  • 2020-12-22 09:26

    In essence what you want is still a loop through integer values incremented by 1. So you can just calculate the last int value and use a simple for each loop:

    for i in 0..<Int(self.frame.size.width / ( skyTexture.size().width * 2.0 )) + 2 {
        //do your stuff here
        sprite.position = CGPoint(x: CGFloat(i) * sprite.size.width, y: sprite.size.height / 2.0 + groundTexture.size().height * 2.0)
    }
    
    0 讨论(0)
提交回复
热议问题