artG artG - 1 year ago 123
iOS Question

How to create realistic ball drop from cliff using swift and UIkit

I try to make the ball with realistic physics when it fall from cliff, as you can see in in image 2. that's what I what to achieve, for now I have what is drawn in image 1.Image of ball phisics

for image 1. I use this code: += 5 -= 4

By the way, in game cliff is slowly going down and ball up, after ball drops from cliff, cliff stops and ball just drop to the floor.

Question how can I make something like what I draw in image 2. Is there a easy way to do this, because I am not yet a good friend with physics.

Answer Source

You will need a logarithm function to generate values for x and y You can check more here: theory

After importing UIKIT or FOUNDATION it will be like this in Swift:

func log2(x: Double) -> Double

func log2f(x: Float) -> Float
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download