Post

Replies

Boosts

Views

Activity

how to randomly spawn enemies on screen
let randomNumber = arc4random_uniform(2) let x: CGFloat = randomNumber == 0 ? 1 : -1 enemy.position = CGPoint(x: (CGFloat(arc4random_uniform(UInt32(UIScreen.main.bounds.width))) * x), y: UIScreen.main.bounds.height) here is my code for enemy spawn, it works but some of my enemies are spawning outside of my screen. What can i change to make them all spawn inside the border
1
0
792
Sep ’21
how to randomly spawn enemies on screen
let randomNumber = arc4random_uniform(2) let x: CGFloat = randomNumber == 0 ? 1 : -1 enemy.position = CGPoint(x: (CGFloat(arc4random_uniform(UInt32(UIScreen.main.bounds.width))) * x), y: UIScreen.main.bounds.height) here is my code for enemy spawn, it works but some of my enemies are spawning outside of my screen. What can i change to make them all spawn inside the border
Replies
1
Boosts
0
Views
792
Activity
Sep ’21
how to make object fall with gravity
How can i change my objects gravity without having my player fall with it. I added physicsWorld.gravity = CGVector(dx: 0, dy: 0) on my players movement and affectedByGravity on both my object and player. If I change dy to -9.8, my object falls but along with my player
Replies
0
Boosts
0
Views
406
Activity
Sep ’21