- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图做到这一点,以便在我触摸场景中的节点时我的游戏能够识别,除非我使用下面的代码,我认为这完全符合我的要求,我的应用程序无法正确识别节点的位置.
我在屏幕的其余部分周围单击,打印出我正在触摸的节点的名称,事实证明我的应用程序认为节点的位置与实际位置不同(x 值是正确的 y值(value)非常低)
你看到什么地方不对了吗?
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch in (touches as! Set<UITouch>) {
var TouchlocationEnd = touch.locationInView(self.view!)
let touchedNode = self.nodeAtPoint(TouchlocationEnd)
var name = touchedNode.name
println(name)
if name == "start"{
var scene = PlayScene(size: self.view!.bounds.size)
scene.scaleMode = .AspectFill
self.view!.presentScene(scene)
}
}
}
最佳答案
根据 Apple 的文档,nodeAtPoint() 函数采用“节点坐标系中的一个点”。但是您找到的点是 View 中的位置,它不一定与您在此处子类化的任何节点位于同一坐标系中。
换句话说,我猜测“self.view”的坐标系与“self”的坐标系不同。尝试这样的事情(未经测试):
let touchPoint = touch.locationInNode( self )
let touchedNode = self.nodeAtPoint( touchPoint )
关于ios - touch.locationInView 没有像我想的那样工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30851229/
我正在使用UIRotationGestureRecognizer,并且在target方法中有以下代码: if (gestureRecognizer.state == UIGestureRecogniz
uitouch 的 locationInView 返回的坐标忽略了设备方向 - 我有一个可以正确旋转的 uiview,但是 locationInview 总是像纵向一样返回... View 覆盖了 l
我正在尝试使用 locationInView 来获取触摸的位置。当我将 locationInView 打印到控制台时,会输出正确的值。但是,当我尝试将其分配给局部变量时,该变量永远不会获取该值,因此我
请帮帮我。我有下一个问题: 我想在我的 UIViewController 子类中处理 touchesMoved: 事件(我有一个带有 View Controller 的 View ),但是当我调用 [
我试图做到这一点,以便在我触摸场景中的节点时我的游戏能够识别,除非我使用下面的代码,我认为这完全符合我的要求,我的应用程序无法正确识别节点的位置. 我在屏幕的其余部分周围单击,打印出我正在触摸的节点的
我已经追踪到问题出在 UITapGestureRecognizer 上的 locationInView: 总是给我纵向的 (0,-67) 和横向的 (0,268) CGPoint。 (如果我不将其转换
我正在迈出 Swift 的第一步 为 UIPanGestureRecognizer 沿 X 坐标移动 UIView 的最佳方法是什么? 通常程序员使用 translationInView 进行平移手势
我有一个 UIPanGestureRecognizer,我可以使用 locationInView 方法,但是当我输入 traslationInView 时,我无法使用它并且系统说:UIGestureR
我是初学者,对他们感到困惑。在控制台中,它们的位置具有不同的值。那么,他们自己的意义是什么? 最佳答案 locationInView 将根据处于纵向模式的正常笛卡尔坐标系为您提供用户触摸的当前位置。
iPhone 开发新手。谁能告诉我为什么 -(IBAction) handleTapGesture:(UIGestureRecognizer *) sender { CGPoint *tapP
我的应用程序运行良好,今天我开始收到这些随机错误 “UITouch”没有可见的@interface 声明选择器“locationInView” 我不明白,因为它在今天之前工作得很好,今天才开始这样做,
我知道 iPhone 的分辨率为 480 x 320,iPad 的分辨率为 1024 x 768,但我不知道如何以编程方式确定。如果能得到任何帮助,我将不胜感激。 最佳答案 UITouch*yourT
是否存在 UITouch 的 locationInView: 不知道视网膜显示器存在(或不存在)的原因?为什么视网膜显示的重新缩放留给开发人员作为任务。我觉得很奇怪。 谢谢, 道格 最佳答案 这是设计
我试图在用户单击特定的 SCNNode 后检索鼠标位置。我最终想要执行 HitTest 来确定单击了哪个 SCNNode。我有以下代码,但是一旦运行该项目,我就会收到一个断言错误,指出:“无法获取 l
我是一名优秀的程序员,十分优秀!