swift - Array with nodes at each index -
I am creating a game with Sprite kit in Spirit, and there are three nodes in my three positions:
self.size.width * 1/6 // left self.size.width * 1/6 // middle itself. Size.width * 1/6 // right I have created an array with three positons so that they can be called randomly:
RedXx X [[Sprax. Wide. 1/6, speaker width * 3/6, self.size.width * 5/6] // the array with three positions randomIndex = Int (arc4random_uniform (UInt32 (randomX.count))) do xPos: CGFloat = randomX [randomIndex] I have another array with three nodes of the gems:
to randomJewels = [SKSpriteNode (imageNamed: "jewel1"), SKSpriteNode (ImageNamed: "jewel2"), SKSpriteNode (imageNamed: "jewel3"),] and I have set the status and size of my generated node:
to 1 = random Jewels [Int (arc4random_uniform (3))] jewel1.anchorPoint = CGPointMake (0.5, 0) jewel1.position = CGPointMake (xPos, self.size.height / 2) jewel1.size.width = 40 Jewel1.s ize.height = 20 self.addChild (jewel1) Three steps must be taken to three random node (Jewel), but if I am creating two other jewelry, they have a The only situation can be because they have three different positions.
How can I do that jewelry catches up to three positions? It can not be zero state, there is a jewel on every x position! Thanks!
When you make a jewel, you need to remove its image and position so that another Neither can jewelery be as follows:
Comments
Post a Comment