0

2 つのエラーが発生します。<= と >= を使用すると、エラーが発生します。

二項演算子 '>= & <=' は、タイプ CGFloat および Int のオペランドには適用できません

 override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
    var speedOfTouch = 30

    for touch: AnyObject in touches {
        let location = touch.locationInNode(self)

        if location.x < CGRectGetMidX(self.frame) {
            square.position.x <= speedOfTouch
            square.physicsBody?.applyImpulse(CGVector(dx: -40, dy: 0))



        }
        else {
            square.position.x >= speedOfTouch
            square.physicsBody?.applyImpulse(CGVector(dx: 40, dy: 0))
        }

    }
}

私は助けが必要です!

4

3 に答える 3

0

1 行を変更します。

let speedOfTouch = CGFLoat(30)

コンパイラが述べているように2つの異なる型を比較できないため、機能しませんでした

于 2015-07-22T20:22:39.263 に答える