Hello I have a problem with my Swift code.
In my application some SKLabelNode
s are supposed to have their y coordinate set to
CGRectGetMaxY(self.frame) - (nodes[i].frame.size.height / 2 + 30) * (i + 4)
Where
var i:Int = 0
is a counter.
It works perfectly fine if instead of (i + 4)
I just give it a literal value e.g. 5
or even (i == 0? 4 : 5)
(just to see on two consecutive integers if the formula is correct itself).
But when I go with any variable or constant or expression containing one, it displays an error "CGFloat is not convertible to Int". It seems completely illogical, because 4
is an integer and so is i
and even (i + 4)
, in which case changing 4
to i
shouldn't change the whole expression's type.
Can anyone explain why do I get this error and how can I possibly solve it?
Thanks in advance.