Tuesday, 15 February 2011

CGPointMake in swift or CGPoint -



CGPointMake in swift or CGPoint -

i want move uiimageview, did in objective-c , worked. code:

tank.center = cgpointmake(tank.center.x + tankx, tank.center.y + tanky);

tankx set in viewdidload 2 , tanky set 0. tank moves right. when want in swift doesn't work. swift code:

tank.center = cgpointmake(tank.center.x + tankx, tank.center.y + tanky)

i tried cgpoint can't working. saw question: cgpointmake in swift couldn't manage utilize it.

does have thought how this?

edit: error: not find overload '+' accepts supplied arguments

i'd seek this:

tank.center = cgpoint(x: tank.center.x + cgfloat(tankx), y: tank.center.y + cgfloat(tanky))

it converts tankx , tanky cgfloats can added other cgfloats.

swift

No comments:

Post a Comment