'予想引数の型に' int型の型の値を変換できません':コードにするCGPoint '
のvar shotLength:するCGPoint = vecMult(方向それは、この行でエラーを示し
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
self.runAction(SKAction.playSoundFileNamed("ball.mp3", waitForCompletion: false))
let touch = touches.first
var location:CGPoint = touch!.locationInNode(self)
var torpedo: SKSpriteNode = SKSpriteNode(imageNamed: "heartbullet")
torpedo.position = player.position
torpedo.physicsBody = SKPhysicsBody(circleOfRadius: torpedo.size.width/2)
torpedo.physicsBody?.dynamic = true
torpedo.physicsBody?.categoryBitMask = photoTorpedoCategory
torpedo.physicsBody?.contactTestBitMask = alienCategory
torpedo.physicsBody?.collisionBitMask = 0
torpedo.physicsBody?.usesPreciseCollisionDetection = true
var offset:CGPoint = vecSub(location, b: torpedo.position)
if (offset.y < 0){
return
}
self.addChild(torpedo)
var direction:CGPoint = vecNormalize(offset)
var shotLength:CGPoint = vecMult(direction, b: 1000)
var finalDestination:CGPoint = vecAdd(shotLength, b: torpedo.position)
let velocity = 568/1
let moveDuration:Float = Float(self.size.width)/Float(self.size.width)/Float(velocity)
var actionArray:[SKAction] = [SKAction]()
actionArray.append(SKAction.moveTo(finalDestination, duration: NSTimeInterval(moveDuration)))
actionArray.append(SKAction.removeFromParent())
torpedo.runAction(SKAction.sequence(actionArray))
}
func vecAdd(a:CGPoint, b:CGPoint)->CGPoint{
return CGPointMake(a.x + b.x, a.y + b.y)
}
func vecSub(a:CGPoint, b:CGPoint)->CGPoint{
return CGPointMake(a.x - b.x, a.y - b.y)
}
func vecMult(a:CGPoint, b:CGPoint)->CGPoint{
return CGPointMake(a.x * b.x, a.y * b.y)
}
func vecLenght(a:CGPoint)->CGFloat{
return CGFloat(sqrtf(CFloat(a.x)*CFloat(a.x)+CFloat(a.y)*CFloat(a.y)))
}
func vecNormalize(a:CGPoint)->CGPoint{
let length:CGFloat = vecLenght(a)
return CGPointMake(a.x/length, a.y/length)
}
、B:1000)
『予想引数の型を『int型の型の値を変換できません』するCGPoint』私は検索してきたと私はそれを修正する方法がわからない
。
誰かが私を助けることができますか?
エラーは「vecMult」の定義にあるように見えますが、あなたはそれを含めていないので、本当の問題が何であるかは分かりません。 –
は、私はあなたがこれに言及していると思う: FUNC vecMult(:するCGPoint、B:するCGPoint) - >するCGPoint { リターンCGPointMake(a.x * b.x、a.y * b.y) } – norm