★ TouchArcade needs your help. Click here to support us on Patreon.

Restricting the size of a line made by touch-SpriteKit (objective-C)

07-19-2014, 02:21 PM
#1
Restricting the size of a line made by touch-SpriteKit (objective-C)

So 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 bodyWithEdgeLoopFromPathathToDraw];
lineNode.physicsBody.categoryBitMask = ballCategory;
lineNode.physicsBody.contactTestBitMask = ballCategory;
[self addChild:lineNode];
I used this in the touch began and touch Moved method,