In order to make window dispose more nature is to make is fade out.
==========================================
First, add def pre_terminate Into the script anywhere.(out side of any other method)
Then add a method "fade" and"dispose"
It should look like this.
def pre_terminate
fade
dispose
end
复制代码
Then below it we add def fade and def dispose
In dispose, you dispose all the window, kind of obvious what to do.....
So we just skip the def dispose
And go to def fade
We are going to use the loop do method to help us
Let's use the Menu Scene as our example...
This is how it should look like....
If XXX is not more than 1, it exit the loop do(using"break") if it's more than 1, it does"........"part over and over
def fade
loop do
if XXX > 1
..........................
else
break
end
end
复制代码
The xxx should be whatever the window you have in your scene like @status_window.opacity
So let's switch to this.....
def fade
loop do
if @status_window.opacity > 1
............
else
break
end
end
复制代码
OK, we will do the ......... part over and over again until @status_window.opacity if more than one.
So we can add @status_window.opacity -= 1 as the .............
Which will fade out the window's opacity by 1 and 1
Also we could add other window's as well!
If you're sure that all window's opacity will be the same (Should be......)
you can just add them toghter... like under @status_window.opacity -= 1 you put @gold_window.opacity -= 1 which will fade out both of them!
So our finishing thing should look like this: (for Meun Scene)
def pre_terminate
fade
dispose
end
def fade
loop do
# a = @status_window.opacity
if @status_window.opacity > 1
@gold_window.opacity -= 1
@command_window.opacity -= 1
@status_window.opacity -= 1
@variable_window.opacity -= 1
else
break
end
end
end
def dispose
@ActorPortrait.dispose
@gold_window.dispose
@command_window.dispose
@status_window.dispose
@variable_window.dispose
end
复制代码
For the other scene, it's exactly the same as well!作者: xTsukihime 时间: 2013-9-25 00:30
I prefer to use update method instead of using a loop.
Here is a script I wrote a year ago that uses the update method to perform animations
Just copy the script into your project and then copy one of the examples I posted under it and open the menu in the game.作者: 熊喵酱 时间: 2013-9-25 12:07
xTsukihime 发表于 2013-9-24 09:30
I prefer to use update method instead of using a loop.
Here is a script I wrote a year ago that uses ...
So basically, I just keep update the window's opacity until it meets the required amount?
but what I don't get is, what is update different from loop do?
(I know I maybe am being stupid, but I just don't get it.....)作者: xTsukihime 时间: 2013-9-25 23:08
The update method is called once every frame. It updates everything like graphics and input and events.
If you loop, the game does not update the graphics, so everything will just freeze until you exit the loop.