查看: 1198|回复: 3

[Other] Fade out/in method

[复制链接]

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

发表于 2013-9-24 07:37:04 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 76213585 于 2013-9-23 22:32 编辑

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.
  1.   def pre_terminate
  2.     fade
  3.     dispose
  4.   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
  1.   def fade
  2.     loop do
  3.       if XXX > 1
  4.          ..........................
  5.       else
  6.         break
  7.       end   
  8.     end
复制代码
The xxx should be whatever the window you have in your scene like @status_window.opacity
So let's switch to this.....
  1.   def fade
  2.     loop do
  3.       if @status_window.opacity > 1
  4.         ............
  5.       else
  6.         break
  7.       end   
  8.     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)
  1.   def pre_terminate
  2.     fade
  3.     dispose
  4.   end
  5.   def fade
  6.     loop do
  7.    # a = @status_window.opacity
  8.       if @status_window.opacity > 1
  9.         @gold_window.opacity -= 1
  10.         @command_window.opacity -= 1
  11.         @status_window.opacity -= 1
  12.         @variable_window.opacity -= 1
  13.       else
  14.         break
  15.       end   
  16.     end
  17.   end
  18.   def dispose
  19.     @ActorPortrait.dispose
  20.     @gold_window.dispose
  21.     @command_window.dispose
  22.     @status_window.dispose
  23.     @variable_window.dispose
  24.   end
复制代码
For the other scene, it's exactly the same as well!

梦石
0
星屑
50
在线时间
135 小时
注册时间
2013-6-10
回帖
28
发表于 2013-9-25 00:30:10 | 显示全部楼层
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

http://himeworks.wordpress.com/2 ... animation-designer/

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.

点评

thanks Tsukihime! I'll look at your script.  发表于 2013-9-25 06:29
回复

使用道具 举报

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

 楼主| 发表于 2013-9-25 12:07:44 | 显示全部楼层
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.....)

回复

使用道具 举报

梦石
0
星屑
50
在线时间
135 小时
注册时间
2013-6-10
回帖
28
发表于 2013-9-25 23:08:14 | 显示全部楼层
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.

回复

使用道具 举报

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本发帖返回顶部