Im trying to build an app with randomly placed objects (SKSpriteNode), I have tried some solutions but nothing is working. In other words, some solutions worked, but they were only placing the objects into one fourth of the screen.
I was trying to find something that would work but Im struggling with that.
Here are some solution I’ve tried.
the first one:
let maxX = (scene?.frame.maxX)!
let maxY = (scene?.frame.maxY)!
let xPos = CGFloat( Float(arc4random()) / Float(UINT32_MAX)) * maxX
let yPos = CGFloat( Float(arc4random()) / Float(UINT32_MAX)) * maxY
and the second one:
let PositionX1 = arc4random_uniform(UInt32(( self .view?.frame.width)! - objectWidth))
let PositionY1 = arc4random_uniform(UInt32(( self .view?.frame.height)! - objectHeight))