设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 934|回复: 3
打印 上一主题 下一主题

[Other] Fade out/in method

[复制链接]

梦石
0
星屑
362
在线时间
1292 小时
注册时间
2013-1-12
帖子
3590

贵宾

跳转到指定楼层
1
发表于 2013-9-24 07:37:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 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
帖子
29
2
发表于 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
星屑
362
在线时间
1292 小时
注册时间
2013-1-12
帖子
3590

贵宾

3
 楼主| 发表于 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
帖子
29
4
发表于 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.

回复 支持 反对

使用道具 举报

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-15 15:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表