How can you spawn SKSpritenodes randomly inside other SKSpritenodes? Maybe using constraints (in Swift)?
For example, I would like circles to spawn in random places inside different square SKSpriteNodes.
How can you spawn SKSpritenodes randomly inside other SKSpritenodes? Maybe using constraints (in Swift)?
For example, I would like circles to spawn in random places inside different square SKSpriteNodes.
In order to do that, it's much better to use CGRects to contain the object that you are going to spawn.
You can use arc4random_uniform to get a random value for both the X and Y coordinates of the object that you are spawning and then use CGRectContainsPoint to check if the location is inside the CGRect.