赞 | 0 |
VIP | 4 |
好人卡 | 43 |
积分 | 94 |
经验 | 75226 |
最后登录 | 2019-3-3 |
在线时间 | 1131 小时 |
Lv4.逐梦者
- 梦石
- 3
- 星屑
- 6420
- 在线时间
- 1131 小时
- 注册时间
- 2007-12-26
- 帖子
- 2402
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 幻耶 于 2009-12-9 10:57 编辑
下面这段脚本的功能是让事件在走动的时候也能说话,也就是让对话框不影响角色和事件的行动,通过事件用脚本 popMessage(50,"对话!") 来调用,但是发现调出对话框但是对话框还没消失的时候如果角色场所移动到了别的地图就如下图出错了,有什么方法解决么?- class Window_PopMessage < Window_Base
- def initialize(id, frames, str)
- @id = id
- @frames = frames
- @pop_fade = 0
- strs = str.split(/$/m)
- temp = Bitmap.new(1, 1)
- temp.font.size = 16
- max_w = 0
- rects = []
- for i in 0...strs.length
- rects.push(temp.text_size(strs[i]))
- width = rects[i].width
- if width > max_w
- max_w = width
- end
- end
- temp.dispose
- max_h = strs.length * 20
- super($game_map.events[@id].screen_x - ((max_w + 32) >> 1),
- $game_map.events[@id].screen_y - max_h - 96,
- max_w + 32, max_h + 32)
- self.contents = Bitmap.new(max_w, max_h)
- self.contents.font.size = 16
- self.z = 1000
- self.opacity = 0
- self.contents_opacity = 0
- for i in 0...strs.length
- rects[i].y = i * 20
- self.contents.draw_text(rects[i], strs[i])
- end
- end
-
- def update
- self.x = $game_map.events[@id].screen_x - (self.width >> 1)
- self.y = $game_map.events[@id].screen_y - self.height - 64
- if @pop_fade == 0
- self.opacity += 10
- self.contents_opacity += 10
- @pop_fade = 1 if self.contents_opacity >= 255
- elsif @pop_fade == 2
- self.opacity -= 10
- self.contents_opacity -= 10
- dispose if self.contents_opacity <= 0
- else
- @frames -= 1
- @pop_fade = 2 if @frames <= 0
- end
- end
- end
- class Scene_Map
- attr_accessor :pop_windows
- alias main_original main unless method_defined? :main_original
- def main
- @pop_windows = []
- main_original
- for i in @pop_windows
- i.dispose unless i.disposed?
- end
- end
- alias update_original update unless method_defined? :update_original
- def update
- i = 0
- while i < @pop_windows.length
- if @pop_windows[i].disposed?
- @pop_windows.delete_at(i)
- else
- @pop_windows[i].update
- end
- i += 1
- end
- update_original
- end
- end
- class Interpreter
- def popMessage(frames, str)
- if !$scene.is_a?(Scene_Map)
- return
- end
- $scene.pop_windows.push(Window_PopMessage.new(@event_id, frames, str))
- end
- end
复制代码 |
|