- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我很难弄清楚应该如何创建一条从 A 点出发并指向 B 点(用户的手指)或更远的线。这样的行可能看起来像
(A) 原点 (B) 手指
A--------B------------
这条线会延伸到屏幕之外,并且当用户移动手指时应该旋转。创建直线并实时移动其 B 坐标的代码也会有所帮助。谢谢!
编辑 - 到目前为止我所做的:
class GameScene: SKScene {
let testball = SKShapeNode(circleOfRadius: 50)
let testguy = SKShapeNode(circleOfRadius: 50)
let line = SKShapeNode()
let pathToDraw = CGPathCreateMutable()
override func didMoveToView(view: SKView) {
self.backgroundColor = UIColor(colorLiteralRed: 0.9, green: 0.9, blue: 1, alpha: 0.5)
testball.fillColor = UIColor.redColor()
self.addChild(testball)
self.testguy.position = CGPointMake(CGRectGetMinX(self.frame) + testguy.frame.width + 10, CGRectGetMinY(self.frame) + testguy.frame.height + 10)
self.testguy.fillColor = SKColor.redColor()
self.addChild(self.testguy)
CGPathMoveToPoint(pathToDraw, nil, testguy.position.x, testguy.position.y)
self.addChild(self.line)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
testball.position = (touches.first?.locationInNode(self))!
CGPathAddLineToPoint(pathToDraw, nil, (touches.first?.locationInNode(self).x)!, (touches.first?.locationInNode(self).y)!)
self.line.path = pathToDraw
self.line.strokeColor = UIColor.redColor()
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
testball.position = (touches.first?.locationInNode(self))!
//print(touches.first?.locationInView(self.view), appendNewline: true);
line.removeFromParent()
testball.position = (touches.first?.locationInNode(self))!
CGPathAddLineToPoint(pathToDraw, nil, (touches.first?.locationInNode(self).x)!, (touches.first?.locationInNode(self).y)!)
self.line.path = pathToDraw
self.line.strokeColor = UIColor.redColor()
self.addChild(line)
}
最佳答案
我明白了!我所要做的就是将 touchesBegan
和 touchesMoved
中的代码更改为
line.removeFromParent()
testball.position = (touches.first?.locationInNode(self))!
let pathToDraw = CGPathCreateMutable()
CGPathMoveToPoint(pathToDraw, nil, testguy.position.x, testguy.position.y)
CGPathAddLineToPoint(pathToDraw, nil, (touches.first?.locationInNode(self).x)!, (touches.first?.locationInNode(self).y)!)
self.line.path = pathToDraw
self.line.strokeColor = UIColor.redColor()
self.addChild(self.line)
在touchesEnded
内部,我编写了self.line.removeFromParent()
,以便在用户触摸屏幕后删除该行。
关于ios - 用户触摸后线路旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31845370/
在典型的 TSP 算法中,我们有多个点,我们希望以最优的行进顺序行进。点是家庭、客户等,基本上是 map 上的一个点。 我有线来优化,而不是点。扫雪机就是一个很好的例子,您可以在多条街道上行驶。最大的
对于我的计算机视觉类(class),我将做一个项目,我将根据走廊的图像提取关于走廊的信息。特别是,向消失点延伸的走廊线会很有趣。我的问题是我是否应该使用 Matlab、OpenCV 或其他东西来实现这
是否有任何工具可以查看 HTTP 2.0 的传输情况(原始请求和响应)?我使用 Fiddler,只看到 HTTP 1.1 数据。 我在 Chrome 中启用了 HTTP 2.0/SPDY 并访问了 h
我们想对我们办公室的两条 ADSL 线路进行负载平衡。 我对 is 的经验有限,想知道是否有人可以为我提供理论之外的解决方案,换句话说,关于硬件和软件要求和建议的细节。 所以我们有 2 条 4mb A
Warning: Error in parsing value for 'display'. Declaration dropped. Line: 0 我不确定当我留下这个警告时会发生什么,因为我没有
我想知道这条 SDP 线的含义是什么,因为我正试图在 5% 到 10% 的数据包丢失情况下获得最平滑的帧速率。 我不知道的行是:a=rtcp-fb:100 goog-remba=rtcp-fb:100
出于某种原因,我在我的所有 CSS 文件中都收到了这个警告/错误,但我不太明白。当我通过 W3C Validator 运行我的 CSS 时结果 100% 有效且格式正确等。但是,在 Firefox 中
我是一名优秀的程序员,十分优秀!