2

I want to draw the line from the bottom right corner of the screen to where the screen is touched using SpriteKit and update the line as the touch position changes. So there's only ONE line on the screen.

I've tried creating a SKShapeNode and update the "path" property as the touch position changes, but that doesn't seem to be very efficent

1 Answers1

4

You're right, it's not very efficient.

The most efficient way (I know of) in SpriteKit is to stretch a very thin SKSpriteNode out, from the position you want it starting, to the touch point.

You'll need to create an SKNode to be the "parent" of your SKSpriteNode, and rotate that so that it acts as an anchor point, with rotation, that looks at the location of the touch.

Then stretch the SKSpriteNode sufficiently so it reaches the location of the touch.

Confused
  • 6,048
  • 6
  • 34
  • 75