i've created a code that creates a line of unlimited size by touch and i'm wondering how to restrict the size such that the beginning and end of the line can be a small distance to a maximum set distance apart?
The code i used was:
pathToDraw = CGPathCreateMutable();
CGPathMoveToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
lineNode = [SKShapeNode node];
lineNode.path = pathToDraw;
lineNode.zPosition = 1000;
lineNode.strokeColor = [SKColor blueColor];
lineNode.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromPath:pathToDraw];
lineNode.physicsBody.categoryBitMask = ballCategory;
lineNode.physicsBody.contactTestBitMask = ballCategory;
[self addChild:lineNode];
in the touch Began Method and
CGPathAddLineToPoint(pathToDraw, NULL, location.x, location.y);
lineNode.path = pathToDraw;
lineNode.zPosition = 1000;
lineNode.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromPath:pathToDraw];
lineNode.physicsBody.categoryBitMask = boundaryCategory;
lineNode.physicsBody.contactTestBitMask = ballCategory;
lineNode.name = @"boundary";
lineNode.physicsBody.restitution=1;
in the touchMoved method.
Thank you