Support our Sponsors:

Go Back   Touch Arcade > Developer Discussion > Public Game Developers Forum

Thread Tools Display Modes
Old 07-19-2014, 03:21 PM
bob_ bob_ is offline
Junior Member
iPod Touch (5th Gen), iOS 7.x
Join Date: Jul 2014
Posts: 3
Default 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,
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 2012,, LLC.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2015, vBulletin Solutions, Inc.
Copyright 2008 - 2011, Privacy Policy / DMCA Copyright Agent