I am working on a project in swift and need to create a new method, where some of the variables initialized with it are not the default constant, in this case specifically in the method itself, I need to modify the variables it is initialized with. After searching for a bit of time, I was wondering how I would do such a thing. The method and its corresponding error are listed below.
func glow(body: SKSpriteNode, NewColor: UIColor, OGColor: UIColor, time: Int, check: Bool, count: Int) {
if check {
body.color = NewColor
count = 0
}
if count >= time {
count = time
}
let RedChangePerFrame = (CGFloat(-1 * (CGFloat(NewColor.rgb()!.red) - CGFloat(OGColor.rgb()!.red)) / 255) / CGFloat(time))
let red = (CGFloat(NewColor.rgb()!.red) / 255) + (RedChangePerFrame * CGFloat(PlayerFadeCount))
let GreenChangePerFrame = (CGFloat(-1 * (CGFloat(NewColor.rgb()!.green) - CGFloat(OGColor.rgb()!.green)) / 255) / CGFloat(time))
let green = (CGFloat(NewColor.rgb()!.green) / 255) + (GreenChangePerFrame * CGFloat(PlayerFadeCount))
let BlueChangePerFrame = (CGFloat(-1 * (CGFloat(NewColor.rgb()!.blue) - CGFloat(OGColor.rgb()!.blue)) / 255) / CGFloat(time))
let blue = (CGFloat(NewColor.rgb()!.blue) / 255) + (BlueChangePerFrame * CGFloat(PlayerFadeCount))
body.color = UIColor(displayP3Red: red, green: green, blue: blue, alpha: 1)
PlayerFadeCount += 1
}
Cannot assign to value: 'count' is a 'let' constant
For additional information, when I run the method I set "count" to a variable called PlayerFadeCount, which is always set to an Int. Any and all help is appreciated!