Now when we have failed transition finished we are going to create another transition.
So you get the feeling on how to create your future transitions also in the next lecture.
We will create one more transition and you will have a better feeling on how to implement your future
transitions.
Now let's go back to our Ga-Ga is inside the simple package.
We're going to create a new Java class superclass will be a screen transition base screen transition
base name will be scaled screen.
So scale screen Tran Zeeshan for this transition we will need.
Few.
So let's add attributes first attributes will be boolean.
Is it scaling out or scaling in.
So let's create private boolean scale out.
Then we need interpellation in Faid transition.
We used fade interpellation but for scale.
You might want to use a different interpellation.
So let's create private interpellation into Polish.
Let's create our constructors constructors first constructor that we need will be constructor that accepts
all parameters.
So alt insert constructor and select bold This will automatically add duration and it will call super
duration or our super construct before we call super adoration.
We are going to Wolley date that our interpellation is not not.
So validate Daut not null interpellation and you can put message interpellation is required.
Or you can leave it without a mess.
Now we need two more constructor.
So let's create first constructed public scale transition scale screen transition.
This construct will help all the two parameters so float duration and bawley and scale out it'll call
the other constructor.
So this duration scale out and for interpellation we will use interpellation linear as default then
we will create another constructor public scale screen transition.
This constructor will just have duration parameter.
And again we will call the other constructor with duration and scale out as follows.
Now the first constructor is calling our second constructor and second constructor is calling out the
constructor.
So don't let this duration false to confuse you.
This is just basic object oriented programming and calling the other construct.
Now let's go back to our Arend method and let's create the public methods section so public metal's
alt insert implement methods.
And we need to implement the render.
So for this we will first interpolate our percentage.
So let's add a little comment in there.
Plate percentage third plate percentage percentage equals interpellation that apply.
So for this transition we can use different interpolations because we can paste them to construct a
play on percentage.
And now we will calculate the scale based on that percentage.
So by default we will assume that it is scale.
So let's add a little comment assume scale out is false.
E.g. scale is Kayleen.
So float scale will be one more played by one minus percent.
If you take a look at this mathematical operation we don't need one more play.
We can just use one minus percent and that will give us the scale values from 1 going to zero because
percentage goes from 1 to zero.
Now we need to check if it is scale out.
Then we want to scale from 0 to 1.
So we will just set the scale.
Equals 2 percent.
Now we need to have a different drawing.
Order if we are scaling out then we want to draw the next screen text first and if we are scaling in
then we want to draw the current screen text first.
So let's add a little comment drawing order depends depends on the scale type.
Is it in or out.
So church top texture is equal to scale out scale out is true then we will use the next screen.
Otherwise we will use card and screen to another texture texture bottom texture will be if skill out
is true then we want the current screen to be our bottom.
Otherwise we want the next screen texture to be our current take and now we need to grab with it and
heights.
So it top texture with it he was top texture top deck and get with it in top texture height equals top
texture get high end and bottom texture with it is equal to bottom texture.
Get with it into the bottom texture height is equal to bottom texture get height.
Now that we have dimensions of our textures it is time to draw the textures so let's add a little comment
drawing GDX UTIs dot Cleave's screen.
First we need to clear the screen.
Then we need to call Bache beggin back to that end and all the drawing in between.
So now first we are drawing the bottom deck.
If we are scaling out then the bottom texture will be the current screen.
And on top of the bottom texture we are going to draw the next screen.
So let's first draw the bottom picture not the whole bottom x x and y 0 0 0 region X and origin y 0
0 with it and height is bottom texture with it bottom texture height scale for bottom texture is one
one rotation is 0 as of C..
X and Y is 0 0 as of C it and height is bottom texture with that bottom texture flip X is false and
flip Y is true.
So that is all we need.
Now you can notice how the scale is 1 what we are just going to scale the top texture.
So for example in your new fact you can rotate one of the textures or you can even scale and rotate
the textures and so you can even drop the portions of textures and create really nice effects.
Now let's drop the top texture.
So I just add almond bottom texture and now top texture better not all top texture X and Y is 0 0 or
region X and Y is the center of top texture so top texture with it divided by two and top texture height
divided by two.
We need to set the origin because the texture will be scaled around that point.
If we set origin to 0 0 then the texture will be scaled around zero zero point or bottom left corner.
We want to scale it in the middle part or in the central part.
Now the radius and height is top texture really height is top texture and scale x and scale y for top
texture the scale that we calculated with interpellation.
So scale coma scale.
The rest is the same.
So rotation is 0 as are C..
X is 0 as a C why is 0 with it and height will be top texture with it top texture height flipping.
False for X and for Y.
And now our scale is getting transition is completed.
So let's try it out inside the screen transition squabs that is located in core package.
Let's create our scale transition.
So public static final screen transition scale equals new screen transition new scale screen transition
and let's put 5 by default it will be scaled out and it'll use into Polish inside out manuscript.
Let me switch to the game screen.
We're going to use a scale screen transition and the same goes for our game screen when we switch back
to menu screen.
So let's set it to scale down.
And now let's run our game and see the scale transition.
It seems it is using the linear interpolation.
Later we will try different in the Appalachians.
So now when I press play you will notice how the screen goes in the center and disappears and the outer
game starts playing which is really nice effect.
It is true that it takes a bit too long.
We can always change duration and now you can notice how slowly our game screen is going to center and
we are back to the menu screen.
So let's change the interpellation.
Let's go to screen transition's scale and let's put for example to F for the duration.
Next parameter is scale out.
So we will set it as true.
So let's get through and for example interpellation let's say Vance out.
Now let's run our game again and see that we are scaling differently this time.
Remember we are we were scaling inside the screen.
So now when I press play before we had many screen going in and now when I press play you will see that
the game screen is coming out from the center.
And these bouncing at the end they toss the balls into play.
So now again if we lose all lifes The game will again go back to manual screen and you can see the menu
screen slowly bouncing.
Let's go back and reword this to five and put bounds in.
For example let's leave it to for the scaling.
Now when we run our game it will be a lot slower.
The transition will be slower.
So let's press play and see how it will work this time.
So now you can see how bouncing is working.
It bounces slowly slowly.
And now when we lose lives the manuscript will come from the center and it will bounce slowly slowly
in.
So you can notice how nice Airfix we can create with these little screen translation API.
You can try all different positions.
So feel free to try different positions like elastic elastic in elastic out.
There are many other interpolations even swing.
Let's try swing in for example instead of bouncing.
Let's try swing in these.
All these are different functions.
And let's set the scale out to false for example.
So our screens scale from the center back to us around your game again.
And now when we press play here and notice how the screen slowly zooms in and then goes back to the
center which is a really nice effect.
And as I said you can really achieve many nice effects with this screen into politicians.
Now you can see the game is zooming out and going back inside the center of the screen.
In the next lesson we will create another transition effect and you will see the different transition
effects.
Let's just change this to point five and I will leave it at 1.5.
You can try different values for your game or different interpretations and see how different effects
you can achieve with these simple interface and implementing one that we can immediately after implementing
the new screen transition we can immediately use it inside our game.
And you can see how modeler this code is.