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)
You could use the userData
property of SKShapeNode
which can be set to an
arbitrary NSMutableDictionary
, for example
sampleSkShapeNode.userData = ["vpos": v, "hpos": h]