0

I'm using SKShapeNode to add rectangles in a n x m matrix. Now I want to store the n x m position in the SKShapeNode. Of course I could simply use the .name property and store the n x m position as string. This has the disadvantage that when I'm trying to access the position I always have to struggle with a string instead of a point.

Is there an easy way to extend the SKShapeNode type in order to get something like this:

sampleSkShapeNode.rectanglePosition -> Point(v,h) 
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
andreaspfr
  • 2,298
  • 5
  • 42
  • 51

1 Answers1

1

You could use the userData property of SKShapeNode which can be set to an arbitrary NSMutableDictionary, for example

sampleSkShapeNode.userData = ["vpos": v, "hpos": h]
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382