Tracking SKSpriteNode

84 views Asked by At

I am fairly new to swift and Sprite Kit. I am trying create a simple game using SKSpriteNodes. My game needs to keep track the sequence of the "clicked" nodes as it needs to be processed based on its sequence. I am thinking of creating a list, as the nodes are clicked it will be added to the list. Is this the easiest way? I am thinking that it may consume more memory. My nodes are of the same names. Below is the method I used in adding the nodes in my scene. I need to know the sequence of colored balls clicked.

for x in listNodes{
    var ballNode = SKSpriteNode(imageNamed: String(color))
    ballNode.name = "ball"

    var point: CGPoint = CGPointMake(0,0)
    var done: Bool = false

    let randomX = randomRange(CGRectGetMinX(self.frame), max: CGRectGetMaxX(self.frame)-(ballNode.size.width))
    let randomY = randomRange(CGRectGetMinY(self.frame) + self.border.size.height, max: CGRectGetMaxY(self.frame)-ballNode.size.height)

    point = CGPointMake(randomX, randomY)

    ballNode.anchorPoint = CGPointMake(0,0)
    ballNode.position = point

    self.addChild(ballNode)
 }
0

There are 0 answers