所以我有一个SpriteNode
在点击时跳起来向右跳。这一切都很棒但是当它跳跃时它会向右移动。如果我继续点击它会跳出屏幕。
我需要精灵向上跳并向右跳并返回它开始的地方。一种对角线跳跃而不是弧线。我该怎么做?
我的代码:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
savior.physicsBody?.velocity = CGVectorMake(0, 0) //pt it returns to?
savior.physicsBody?.applyImpulse(CGVectorMake(5, 30)) //direction/height that it jumps
if UIDevice().iPhone6plus {
savior.physicsBody?.velocity = CGVectorMake(0, 0) //pt it returns to?
savior.physicsBody?.applyImpulse(CGVectorMake(0, 12)) //direction/height that it jumps
}
if UIDevice().iPad2 {
savior.physicsBody?.velocity = CGVectorMake(0, 0) //pt it returns to?
savior.physicsBody?.applyImpulse(CGVectorMake(0, 140)) //direction/height that it jumps
}
}