首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >touchesBegan不适用于多个触摸

touchesBegan不适用于多个触摸
EN

Stack Overflow用户
提问于 2015-07-29 12:02:28
回答 1查看 544关注 0票数 0

我的touchesBegan对于发生的每个不同的触摸事件都能正常工作,但当我同时在两个不同的位置触摸时除外。我总是不得不抬起一根手指,然后才能放下另一根手指。有没有一种方法可以让touchesBegan (希望还有touchesMoved)同时工作于两种不同的风格?在我的项目中,我有一把剑,如果你点击刀柄,它会平移剑,如果你点击刀片,它会旋转剑,但如果你同时点击这两把剑,剑就会飞满屏幕。

代码语言:javascript
复制
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
    /* Called when a touch begins */
    for touch in (touches as! Set<UITouch>) {
        let location = touch.locationInNode(self)
        dx = location.x - Handle.position.x
        dy = location.y - Handle.position.y
        locationAngle = atan2(dy, dx)
        if (HandleTouch.containsPoint(location)){
            touchedHandle = true
        }
        else if (BladeTouch.containsPoint(location)){
            touchedBlade = true
        }
    }
}
EN

回答 1

Stack Overflow用户

发布于 2015-07-29 12:14:00

确保视图的multipleTouchEnabled属性设置为true,您可以在代码中或使用界面生成器中的“多点触摸”复选框来执行此操作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31691034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档