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

Discussion in 'Public Game Developers Forum' started by bob_, Jul 19, 2014.

  1. bob_

    bob_ New Member

    Jul 19, 2014
    3
    0
    0
    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 bodyWithEdgeLoopFromPath:pathToDraw];
    lineNode.physicsBody.categoryBitMask = ballCategory;
    lineNode.physicsBody.contactTestBitMask = ballCategory;
    [self addChild:lineNode];
    I used this in the touch began and touch Moved method,
     

Share This Page