class GameScene: SKScene,SKPhysicsContactDelegate {overrIDe func dIDMovetoVIEw(vIEw: SKVIEw) { /* Setup your scene here */ // physics & collisions physicsWorld.gravity = CGVectorMake(0.0,0.0) physicsWorld.contactDelegate = self // Swipe down let swipeDown:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self,action: Selector("swipedDown:")) swipeDown.direction = .Down vIEw.addGestureRecognizer(swipeDown)}//MARK: Swipesfunc swipedDown(sender:UISwipeGestureRecognizer){ //first function swipeDown()}//MARK: touchesoverrIDe func touchesBegan(touches: Set<UItouch>,withEvent event: UIEvent?) { /* Called when a touch begins */ for touch in touches { let location = touch.locationInNode(self) // second function attack() }}}解决方法 而不是touchesBegan,尝试使用轻击手势(UITapGestureRecognizer)进行攻击 *** 作.
这不是必需的,但如果在滑动和点击之间仍然存在冲突,请使用requireGestureRecognizerToFail使轻击手势取决于滑动失败,以确保在滑动过程中未检测到轻击.
总结以上是内存溢出为你收集整理的ios – 如何在spriteKit和swift中区分手势和触摸?全部内容,希望文章能够帮你解决ios – 如何在spriteKit和swift中区分手势和触摸?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)