Come back again this isn't going to talk about spring animation.
And to be honest this spring image is not something that you use it every day but it's kind of useful
from time to time so I decided that show it to you in this lesson really quickly so you get a sense
of how it is done.
So this going into school I'm going to start a new project called Spring animation and for my spring
animation I'm going to have a target that a box or a ball is going to try to reach you.
So to do that I want to go to my storyboard in the storyboard I'm going to have a white view that I'm
going to play some like in here and that's the one that we're going to animate so I'm going to say 64
by 64.
It has a red back on something like that.
And then I'm going to have a label on that label.
I'm going to place it somewhere here.
I'm only going to show a cross on it as if this is the place we're trying to reach to.
Not that sign this sign something like that.
And of course I need an animation but then I'm going to add a button say this one that is going to run
the animation for us.
So I'm going to go ahead and say This one is animate and the animate has a background color such as
that one and that's all the stuff that we need for the storyboard.
So I want to go to the assistant editor in the assistant window.
I'm going to go ahead and say this is the animate function animate action.
It is an action connected.
This is obviously the red box as usual.
And this little fellow in here is going to be let's call it Center label is the one that shows us the
center we are trying to reach to essentially.
So I'm going to go back to my view control and clear things up.
And when I have a bit there I think I don't mean you.
I want to get rid of it.
I only need this one function that has to actually do something for me.
So let's go in here and say when we call the animation action do this say you why do you not animate.
And what I'm looking for is the one that has a spring built into it and you can just go through these
and look down in here and it will show you what are the different options in that one.
And as they go through this one is the one that corresponds to the motion of a physical spring and that's
the one that they want to use.
So I'm going to say this is like all the different arguments so I can see them easier.
And in you year I'm going to go ahead and say let's get rid of the ration of maybe five seconds and
I'm going to give it no delay at the beginning.
I'm going to say the animation damping or that's the screen damping how it decays and how it dies.
When I say it I'd say 20 to five and then I'm going to say give it an initial velocity of maybe three.
And then I will have more options.
And in the animation I will have only one thing.
So I'm going to say self not red box start center becomes center labeled Dart Center and that means
the self as well because we are within the closure.
I don't want to have anything on the completion just now.
So that's all we have to do for a spring animation.
He's going to try to DK The animation attenuate the animation with a rate of point to five.
Let's see how it shows up when we actually run it on the on the simulator.
You can play on the numbers like I said it's something interesting to know.
Pi is not something you would be using it every day.
So that's like a down animation they joys off as it tries to reach there.
Just increase the initial velocity to ten.
So they give it a quick you know try to see how they actually affect the animation.
And now if they run it again we see that it has a stronger beginning and then it DKs with the same rate.
And if I increase the decay to say point eight or a larger number with a larger damping I expect it
to die off faster.
So it goes and comes and that's it.
So a larger damping cause is less of a bounciness essentially Iran this spring.
So that's a very simple one.
Keep it in mind in case one day you need it.
We have another physics engine that we will be talking about it that is the dynamics.
We also have another much more advanced physics engine which is the sprite kit and the scene kit.
Both of these have come in quite a few sections from now and I'll see you in the next lesson as well
as those.