Joseph
Joseph

Reputation: 23

Troubles with Swift 2 Xcode 7.3.1

Im getting a bit of an error with my code and need help with fixing errors. heres what the error is telling me:

Cannot pass immutable value to mutating operator: function call returns immutable value

heres the code with it

for var i:CGFloat = 0; i<2 + self.frame.size.width / (MovingGroundTexture.size().width); ++1 {
        let groundsprite = SKSpriteNode(texture: MovingGroundTexture)
        groundsprite.zPosition = 0
        groundsprite.anchorPoint = CGPointMake(0, 0)
        groundsprite.position = CGPointMake(i * groundsprite.size.width, 0)
        addChild(groundsprite)

Upvotes: 0

Views: 38

Answers (1)

Feldur
Feldur

Reputation: 1169

The way I read your loop, you've written ++1 and not ++i. You can't increment the constant, of course.

Upvotes: 3

Related Questions