GK Random Distribution

Hi, i'm trying to get a certain element to appear on my iphone xr in xcode 10 but it wont work. If anyone could explain how that works that would be super!

@objc func addAlien () {
possibleAliens = GKRandomSource.sharedRandom().arrayByShufflingObjects(in: possibleAliens) as! [String]

    let alien = SKSpriteNode(imageNamed: possibleAliens[0])
    
    let randomAlienPosition = GKRandomDistribution(lowestValue:0, highestValue:20 )
    let position = CGFloat(randomAlienPosition.nextInt())
    
    alien.position = CGPoint(x: position, y: self.frame.size.height + alien.size.height)

i'm trying to get a certain element to appear on my iphone xr in xcode
10 but it wont work.

This question is very specific to Apple frameworks, so you might have more luck asking it somewhere dedicated to those frameworks, like the Graphics and Games > SpriteKit topic area on DevForums.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Terms of Service

Privacy Policy

Cookie Policy