【问题标题】:Missing Argument for Parameter 'y' in Call调用中缺少参数“y”的参数
【发布时间】:2015-11-06 16:29:21
【问题描述】:

使用 Xcode + Swift + SpriteKit 这是我的代码:

let scaleMove = SKAction.moveByX(CGPoint(x:CGRectGetMaxX(self.frame)-30,y:CGRectGetMinY(self.frame)+30, duration: 5))

我不知道该怎么做,你有争论。然而它没有?

顺便说一句,如果你没有收到错误:'Missing Argument for Parameter 'y' in Call'

【问题讨论】:

    标签: swift sprite-kit


    【解决方案1】:

    仔细查看您传递给函数的第一个参数,您忘记了右括号,您尝试传递 CGPoint 但它需要 CGFloat 并且最后有两个括号但它应该只是一个:

    let scaleMove = SKAction.moveByX(
    // 1st param
    CGPoint(x:CGRectGetMaxX(self.frame)-30,   <- missing parenthesis and also missing y parameter for CGPoint initialisation and you cannot pass CGPoint where it expect CGFloat
    // 2nd param
    y:CGRectGetMinY(self.frame)+30, 
    // 3th param
    duration: 5))   <- too many parenthesis, remove one
    

    应该是这样的:

    let scaleMove = SKAction.moveByX(
    CGRectGetMaxX(self.frame)-30,
    y:CGRectGetMinY(self.frame)+30, 
    duration: 5)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-01
      • 2017-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多