So will come back again in this exercise.
You have to use what you have learned from both of you animations as well as the animation blocks or
either of them that you think you can manage it to make an animation loop the animation loop is essentially
something that you have a little you eye view or any kind of outlet that passes through the screen over
and over and over every time it goes from left to right and it reaches the right side of the screen
then jumps by the beginning and read does the exact same thing.
Let me show you what they mean in the actual simulator.
This is the animation loop that I wanted to produce a little UI view as code red box that goes from
left to right continuously.
So keep that in mind.
Pause the video if you want to and give it a try and then if you want it you can have a look at my solution
as well.
OK.
So I'm going to start those then I'm going to go to ex-school make your project called animation.
And in my estimation look the only thing I need in this story.
What is the red box.
So that's going to be a you view.
I'm going to make it maybe 128 by one hundred twenty eight points and a bank on that is right load up
my assistant and say this is red X.
That's essentially all I have to do in the visual side of the mouth.
So here is how I'm thinking of doing this animation and thinking of resetting the position to the utmost
left running animation.
Once animation is done the reset again.
So I want to do this process over and over.
So I want to reset the position of this red box to the utmost left corner of the screen then the animation
until the utmost right.
Then once it is done I want to reset.
So when I reset the get to the left we run the animation.
We get that right.
Then we reset and we keep doing this over and over and over.
So let's go ahead and write all of these.
In our programming language as opposed to our literal language.
So here I'm going to go ahead and say I have a function called reset and my reset function does this
says red box dot center becomes a C.G. point of two values.
One of those values.
Why is the one they don't want to change.
Red Box dot center dot why the X-File you however wants to become 0.
It wants to go to the most left corner of the screen.
So that's the reset one and have another function function called animate and my animated DAW's this
and we get a better formatting up every function by default is void.
So you could either keep it here or drop it.
Essentially this one and Gathorne are exactly the same thing.
They both have no returns.
So in the animate I'm going to say you I you dot animate with completion let's say within two seconds
I want to do an animation of making the red box Center to become CGU point of these values and the values
are these X doesn't.
So why doesn't change so the why is it stays there.
X however become self taught to view that frame.
Dr. V so x essentially goes as far right to the utmost right side of the screen.
Why the red boxes.
Why doesn't change the center.
Why it stays intact essentially I should remember using self more often and then at completion when
the completion happens I want to say reset again.
So reset let's look back at all the code once again at the beginning of the animation was the beginning
of the application.
I'm going to say reset.
So when I reset we go all the way to the left side of the screen but we don't begin the animation since
we don't do that.
And when I say well do a self Da'ath animate.
So at the very beginning we go all the way to the zero and I start animating when the animation happens.
The animation goes through the when it completes.
And when I say self that reset valuation.
So the research takes us to the left animate animates us to the right and then resets and that's all
we have to do for here.
Go ahead and run this see Forget what you are hoping to get.
That's about that.
Now if you want to be super careful you would actually account for the sides of the red box to completely
disappear and then reappear.
So I can show you how you could do that.
Let me show you how to do that for the reset.
I'm going to say go back to the left as much as the weight of the red box divided by two.
And in the negative direction.
So does that mean it means negative red box dot frame size dot net divided by two.
So Pushit to the left as much as one half beat as well to the left and for the animate.
I'm going to go ahead and say Let me get myself a little more space.
Say go to the furtherest point on the screen.
But that's going to be the center of the red box not the left corner of it.
When I say add a little value to it self read box.
I remember to solve this time frame dot sized dot vet divided by two.
So when you go with the left subtract one half with as well for you go to the right and one half with
as well.
So let's see it again.
Yes.
That's exactly how I want it to be.
So that's a very simple exercise.
It shows you a lot of things about how to combine a lot of the code that we all really have learned
because that's most of what programming is about.
It's not about this groundbreaking finding some weird new technology is about knowing how to use the
things you already know properly.
So let's move on to our next lesson.