赞 | 287 |
VIP | 11 |
好人卡 | 74 |
积分 | 227 |
经验 | 281171 |
最后登录 | 2024-11-30 |
在线时间 | 9422 小时 |
Lv5.捕梦者 (暗夜天使) 只有笨蛋才会看到
- 梦石
- 1
- 星屑
- 21706
- 在线时间
- 9422 小时
- 注册时间
- 2012-6-19
- 帖子
- 7119
|
本帖最后由 喵呜喵5 于 2014-3-4 16:56 编辑
- #--------------------------------------------------------------------------
- # ● 喵呜喵5的定制窗口脚本
- #--------------------------------------------------------------------------
- class Window_M520140303 < Window_Base
-
- X1 = 300
- #初始的X坐标
-
- Y1 = -100
- #初始的Y坐标
-
- X2 = 300
- #最终的X坐标
-
- Y2 = 0
- #最终的Y坐标
-
- SPEED_X = 2
- #X方向移动的速度
-
- SPEED_Y = 2
- #Y方向移动的速度
-
- WIDTH = 102
- #窗口宽度
-
- HEIGHT = 100
- #窗口高度
-
- Z = 999
- #窗口的Z坐标
-
- BACKFILE = "Back"
- #窗口背景图片的文件名,放到Graphics/System/下
-
- SWI = 1
- #关闭本脚本的开关ID
-
- def refresh
- contents.clear
-
- #下面设置需要描绘的内容
- word = $game_variables[83]
- draw_text_ex(0,-2, word)
-
- #上面设置需要描绘的内容
-
- save_var_data
- end
-
- #--------------------------------------------------------------------------
- # ● 下面的内容如果你不理解的话不建议你随意修改
- #--------------------------------------------------------------------------
-
- #--------------------------------------------------------------------------
- # ● 设置写者方法
- #--------------------------------------------------------------------------
- attr_writer :come_out
- #--------------------------------------------------------------------------
- # ● 载入
- #--------------------------------------------------------------------------
- def initialize
- super(X1,Y1,WIDTH,HEIGHT)
- self.arrows_visible = false
- self.z = Z
- self.opacity = 0
- create_back_sprite(BACKFILE)
- @come_out = false
- update_show
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 生成背景
- #--------------------------------------------------------------------------
- def create_back_sprite(back)
- return if Dir.glob("Graphics/System/" + back + ".*").empty?
- @background_sprite = Sprite.new
- @background_sprite.bitmap = Cache.system(back)
- @viewpoint = Viewport.new(0,0,Graphics.width * 2,Graphics.height * 2)
- @viewpoint.z = self.z - 1
- @background_sprite.viewport = @viewpoint
- update_background
- end
- #--------------------------------------------------------------------------
- # ● 更新
- #--------------------------------------------------------------------------
- def update
- super
- come_effect(X1,Y1) if @come_out
- return if @come_out
- come_effect(X2,Y2) if come_in?
- refresh if need_refresh?
- update_show
- end
- #--------------------------------------------------------------------------
- # ● 判定是否需要隐藏窗口
- #--------------------------------------------------------------------------
- def update_show
- return if @swi == $game_switches[SWI]
- @background_sprite.visible = self.visible = !$game_switches[SWI]
- @swi = $game_switches[SWI]
- end
- #--------------------------------------------------------------------------
- # ● 判定是否需要进入
- #--------------------------------------------------------------------------
- def come_in?
- (self.x != X2 || self.y != Y2) and (!@come_out)
- end
- #--------------------------------------------------------------------------
- # ● 判定是否完成移出
- #--------------------------------------------------------------------------
- def come_out?
- (self.x == X1 && self.y == Y1) || !self.visible
- end
- #--------------------------------------------------------------------------
- # ● 移动窗口
- #--------------------------------------------------------------------------
- def come_effect(x,y)
- x = self.x - x < 0 ? 1 : (self.x == x ? 0 : -1)
- y = self.y - y < 0 ? 1 : (self.y == y ? 0 : -1)
- x *= SPEED_X
- y *= SPEED_Y
- self.x += x
- self.y += y
- update_background
- end
- #--------------------------------------------------------------------------
- # ● 更新窗口背景的位置
- #--------------------------------------------------------------------------
- def update_background
- return if !@background_sprite
- @background_sprite.x = self.x
- @background_sprite.y = self.y
- end
- #--------------------------------------------------------------------------
- # ● 记录当前窗口显示的内容
- #--------------------------------------------------------------------------
- def save_var_data
- v = $game_variables
- @var1,@var2,@var3,@var4 = v[83],v[84],v[85],v[86]
- end
- #--------------------------------------------------------------------------
- # ● 判定窗口是否需要更新
- #--------------------------------------------------------------------------
- def need_refresh?
- v = $game_variables
- @var1 != v[83] ||@var2 != v[84] ||@var3 != v[85] ||@var4 != v[86]
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- @viewpoint.dispose if @viewpoint
- @background_sprite.dispose if @background_sprite
- end
- end
- #--------------------------------------------------------------------------
- # ● Scene_Map
- #--------------------------------------------------------------------------
- class Scene_Map < Scene_Base
- #--------------------------------------------------------------------------
- # ● 载入窗口
- #--------------------------------------------------------------------------
- alias m5_20140303_create_all_windows create_all_windows
- def create_all_windows
- m5_20140303_create_all_windows
- @m5_20140303_window = Window_M520140303.new
- end
- #--------------------------------------------------------------------------
- # ● 移除窗口
- #--------------------------------------------------------------------------
- alias m5_20140303_pre_terminate pre_terminate
- def pre_terminate
- m5_20140303_pre_terminate
- @m5_20140303_window.come_out = true
- update until @m5_20140303_window.come_out?
- end
- end
复制代码 |
|