本文介绍了CGPointMake在Swift中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Swift 中使用 CGPointMake ?有它的等价物吗?我收到错误:

基本上,我正在尝试为Sprite Kit节点分配一个位置,但无法弄清楚如何在Swift中执行此操作。

  class PlayerSpaceship:Spaceship {

func launchMissile(){

var missile = missile.playerMissile()

/ /该行给出了上述错误。
missile.position = CGPointMake(0.0,0.0)
}
}


CGPoint(x:Float,y:Float)


How to use CGPointMake in Swift? Is there an equivalent for it? I am getting an error:

Basically, I am trying to assign a position to a Sprite Kit node and cannot figure out how to do it in Swift.

class PlayerSpaceship: Spaceship {

    func launchMissile() {

        var missile = Missile.playerMissile()

        // This line gives above mentioned error.
        missile.position = CGPointMake(0.0, 0.0)
    }
}
解决方案

Use CGPoint(x: Float, y: Float)

这篇关于CGPointMake在Swift中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 10:24