![](/img/trans.png)
[英]Drawing straight line with spritekit and UITouch creates multiple lines
[英]Create a straight line with SpriteKit
如何使用SpriteKit和UITouch
創建一條直線?
我想要一個允許我添加起點和終點而不是路徑的方法。 就像橡皮筋一樣。
當用戶開始觸摸運動(例如在touchesBegan:
時, 創建一個SKShapeNode
作為行。
SKShapeNode *line = [SKShapeNode node]; CGPoint startPoint = CGPointMake(..., ...) CGPoint endPoint = CGPointMake(..., ...) CGMutablePathRef pathToDraw = CGPathCreateMutable(); CGPathMoveToPoint(pathToDraw, NULL, startPoint.x, startPoint.y); CGPathAddLineToPoint(pathToDraw, NULL, endPoint.x, endPoint.y); line.path = pathToDraw; line.strokeColor = [UIColor redColor]]; [self addChild:line];
修改其路徑以更改touchesMoved:
長度touchesMoved:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.