简体   繁体   English

Swift“无法使用类型为((@lvalue CGFloat,$ T7)'的参数列表调用'-='

[英]Swift "Cannot invoke '-=' with argument list of type '(@lvalue CGFloat, $T7)'

Can someone please explain to me why I am getting this error message when I try to run this code: 有人可以向我解释为什么在尝试运行此代码时为什么收到此错误消息:

let sprite = SKSpriteNode(imageNamed:"Spaceship")

sprite.xScale = 0.5
sprite.yScale = 0.5
sprite.position = location

self.addChild(sprite)

var dt: Float = 1.0/60.0

sprite.position.x -= 100.0*dt;

The error message appears on the last line by the way 错误消息出现在最后一行

you need to change dt to CGFloat because sprite.position.x have type of CGFloat 您需要将dt更改为CGFloat因为sprite.position.x具有CGFloat类型

var dt: CGFloat = 1.0/60.0

in Swift, arithmetic operators require both operands have same type 在Swift中,算术运算符要求两个操作数具有相同的类型

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不能使用类型的参数列表($ T12,@lvalue CGFloat)调用* - cannot invoke * with an argument list of type ($T12, @lvalue CGFloat) 无法使用类型为(($ T7,$ T14)'的参数列表调用'*' - Cannot invoke '*' with an argument list of type '($T7, $T14)' 在Swift中收到“无法使用类型'((),CGFloat)'的参数列表调用'CGPointMake'” - “Cannot invoke 'CGPointMake' with an argument list of type '((), CGFloat)'” received in Swift 无法使用类型为(CGFloat)的参数列表来调用类型为CGFloat的初始化程序 - Cannot invoke initializer for type 'CGFloat' with an argument list of type '(CGFloat)' Xcode:无法为类型为“(CGFloat)”的参数列表调用类型为“ String”的初始化程序 - Xcode: Cannot invoke initializer for type 'String' with an argument list of type '(CGFloat)' Swift无法使用类型为'(Int @lvalue [Int])'的参数调用'==' - Swift cannot invoke '==' with an argument of type '(Int @lvalue [Int])' Swift:无法使用类型为'($ t3,NSString)'的参数列表调用'init' - Swift: Cannot invoke 'init' with an argument list of type '($t3, NSString)' Swift 2 无法使用类型参数列表调用“FSEventStreamCreate” - Swift 2 Cannot invoke 'FSEventStreamCreate' with an argument list of type Swift:无法使用类型为参数的列表调用“追加” - Swift: Cannot invoke 'append' with an argument list of type 无法使用swift中的类型参数列表调用Method - Cannot invoke Method with an argument list of type in swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM