3

i have searched up the net and found this answer on stack overflow here

the answer didn't quit satisfy what i want , maybe because it was written in objective c .

i searched the net about how to circle a SKSpriteNode and didn't find an answer ,nevertheless here is some of the code i tried:

let cropNode = SKCropNode()
let mask = SKShapeNode()
mask.path(CGPathCreateWithRoundedRect(CGRectMake(-15, -15, 30, 30), 4, 4, nil));
// ↳ '(CGPath!)-> $T13' is not identical to 'CGPath'

cropNode.maskNode(mask)
// ↳ cannot convert the expression's type 'SKShapeNode'to type 'SKNode?'
cropNode.addChild(plate)

errors are shown as comments above.

i want to make my SKSpriteNode round cornered or in other words , make it a circle. here is my declared SKSpritenode:

 var foodarea = SKSpriteNode(imageNamed: "plate")

this is the image that i want to circle ,and is shown here

Thanks!

Community
  • 1
  • 1

1 Answers1

3

You seem to be confusing function call syntax with assignment syntax.

let cropNode = SKCropNode()
let mask = SKShapeNode()
mask.path = CGPathCreateWithRoundedRect(CGRectMake(-15, -15, 30, 30), 4, 4, nil)
cropNode.maskNode = mask
rob mayoff
  • 375,296
  • 67
  • 796
  • 848