Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Spritekit弹球翻转器物理_Ios_Macos_Swift_Sprite Kit_Game Physics - Fatal编程技术网

Ios Spritekit弹球翻转器物理

Ios Spritekit弹球翻转器物理,ios,macos,swift,sprite-kit,game-physics,Ios,Macos,Swift,Sprite Kit,Game Physics,我有个小问题。 我使用以下代码: override func keyDown(theEvent: NSEvent) { let s: String = String(self.returnChar(theEvent)!) switch(s){ case "w": self.moveRightFlipper() default: println("default") } } func moveRightFlipper(){

我有个小问题。 我使用以下代码:

override func keyDown(theEvent: NSEvent) {
    let s: String = String(self.returnChar(theEvent)!)
    switch(s){
    case "w":
        self.moveRightFlipper()
    default:
        println("default")
    }
}

func moveRightFlipper(){
    //do something
    //self.rotatePoint.zRotation += CGFloat(-0.50)
    self.busy = true
}

override func update(currentTime: CFTimeInterval) {

    if(self.busy == true && ticks < 5){
        self.rotatePoint.zRotation += CGFloat(-0.2)
        ticks++
    }
    else if(self.busy == true && ticks < 10){
        self.rotatePoint.zRotation += CGFloat(0.2)
        ticks++
    }
    if(ticks == 10){
        ticks = 0
        busy = false
    }
}
override func keyDown(事件:NSEvent){
让s:String=String(self.returnChar(theEvent)!)
开关{
案例“w”:
self.moveRightFlipper()
违约:
println(“默认”)
}
}
func moveRightFlipper(){
//做点什么
//self.rotatePoint.zRotation+=CGFloat(-0.50)
self.busy=true
}
覆盖函数更新(currentTime:CFTimeInterval){
if(self.busy==true&&ticks<5){
self.rotatePoint.zRotation+=CGFloat(-0.2)
滴答声++
}
else if(self.busy==true&&ticks<10){
self.rotatePoint.zRotation+=CGFloat(0.2)
滴答声++
}
如果(刻度==10){
滴答声=0
忙=假
}
}
一切都正常,只是我碰到了一个小问题,当我触摸w键时,脚蹼并不总是与球碰撞(我想它会移动到它上面或其他东西),然后球会从脚蹼上掉下来,他们有解决办法吗?
非常感谢

将球上连接的物理体上的
usesprecisiondetection
属性设置为
true
。我还建议您使用SKAction旋转您的脚蹼,但我认为没有必要使碰撞正常工作。

我有一个附带问题:为什么您使用键盘事件而不是让用户直接触摸脚蹼?键盘事件只是为了在我的mac上测试,用鼠标多次触摸是不可能的,这是最快的方法(将方法作为osx应用程序进行测试,并将事件转换为最终应用程序的触摸事件)