查看: 6047|回复: 8

[已经解决] 怎样在Window里调用self.dispose呢???

[复制链接]
梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2021-3-9 10:40:45 | 显示全部楼层 |阅读模式
悬赏77星屑已解决
本帖最后由 alexncf125 于 2021-3-9 10:48 编辑

这个显示弹幕的脚本可以在149行当@over为true时调用close(self.dispose)
显示弹幕的脚本
  1. =begin
  2.     #==============================================================================
  3.     # ■ 显示弹幕 V1.1
  4.     #------------------------------------------------------------------------------
  5.     #  在任意场景显示弹幕。
  6.     #==============================================================================
  7.       #----------------------------------------------------------------------------
  8.       # ● 作者
  9.       #----------------------------------------------------------------------------
  10.       rpg-sheep(小优)
  11.       #----------------------------------------------------------------------------
  12.       # ● 原创度
  13.       #----------------------------------------------------------------------------
  14.       100%
  15.       #----------------------------------------------------------------------------
  16.       # ● 使用方法
  17.       #----------------------------------------------------------------------------
  18.       RS::Biu.start(speed) 以每帧speed个像素向左移动的速度开启弹幕。
  19.         注意:重复调用会导致上一个start的弹幕立即消失,没有什么太大影响。
  20.         参数:speed:移动速度,单位为像素,即每帧(1/60)秒移动speed个像素。
  21.         例子:RS::Biu.start(5) # 以每秒5 * 60 = 300像素的速度移动。
  22.       RS::Biu.send(text, up, down, y)在已经start的情况下立即输出一段弹幕。
  23.         注意:如果没有正在start的弹幕,什么都不会发生。
  24.         参数:text:要输出的文字,允许使用\\C[9]这样的代码。
  25.               up:上边距。如不填默认为50。
  26.               down:下边距。如不填默认为50。
  27.               y:弹幕显示的y坐标。如不填则根据up和down随机取值,如填则为定值。
  28.         例子:RS::Biu.send("小优很萌") # 随机在上边距50~下边距50内输出“小优很萌”。
  29.       RS::Biu.send_b(index, up, down, y) 同上,只是从数据库里调用。index是数据库的第几个。
  30.       RS::Biu.over 结束弹幕的滚动以释放内存。调用这个方法后会等待弹幕移动结束再关闭。
  31.         注意:调用over后就不可以使用send方法了。除非新start。
  32.                   弹幕的运行不会耗费太大的内存。所以不用每次发完弹幕后都调用over。
  33.       #----------------------------------------------------------------------------
  34.       # ● 使用条例
  35.       #----------------------------------------------------------------------------
  36.       作为rpg-sheep的100%原创脚本:
  37.       可以在非商业作品中自由使用及修改。(遵守FSL协议)
  38.       禁止在商业作品中使用,禁止修改本脚本后发布。
  39.      
  40. =end
  41.      
  42.     #==============================================================================
  43.     # ■ RS
  44.     #------------------------------------------------------------------------------
  45.     #  rpg-sheep的超类
  46.     #==============================================================================
  47.     module RS
  48.     end
  49.     $window_biu = []
  50.     #==============================================================================
  51.     # ■ Biu
  52.     #------------------------------------------------------------------------------
  53.     #  弹幕类
  54.     #==============================================================================
  55.     module RS::Biu
  56.       #--------------------------------------------------------------------------
  57.       # ● 开始
  58.       #--------------------------------------------------------------------------
  59.       def self.start(speed)
  60.         $window_biu[0].close if $window_biu[0] && !$window_biu[0].disposed?
  61.         $window_biu[1].close if $window_biu[1] && !$window_biu[1].disposed?
  62.         $window_biu[2].close if $window_biu[2] && !$window_biu[2].disposed?
  63.         $window_biu[0] = Window_Biu.new(speed)
  64.         $window_biu[1] = Window_Biu.new(speed)
  65.         $window_biu[2] = Window_Biu.new(speed)
  66.       end
  67.       #--------------------------------------------------------------------------
  68.       # ● 发送
  69.       #--------------------------------------------------------------------------
  70.       def self.send(text, up = 50, down = 50, y = rand(Graphics.height - up - down - 24) + up)
  71.         $window_biu[0].add(text, y) if $window_biu[0] && !$window_biu[0].disposed? && $window_biu[0].x > 0
  72.         $window_biu[1].add(text, y) if $window_biu[1] && !$window_biu[1].disposed? && $window_biu[1].x > 0 && $window_biu[0].update?
  73.         $window_biu[2].add(text, y) if $window_biu[2] && !$window_biu[2].disposed? && $window_biu[2].x > 0 && $window_biu[1].update?
  74.       end
  75.       #--------------------------------------------------------------------------
  76.       # ● 发送(从数据库)
  77.       #--------------------------------------------------------------------------
  78.       def self.send_b(index, up = 50, down = 50, y = rand(Graphics.height - up - down - 24) + up)
  79.         $window_biu[0].add(biulist(index), y) if $window_biu[0] && !$window_biu[0].disposed? && $window_biu[0].x > 0
  80.         $window_biu[1].add(biulist(index), y) if $window_biu[1] && !$window_biu[1].disposed? && $window_biu[1].x > 0 && $window_biu[0].update?
  81.         $window_biu[2].add(biulist(index), y) if $window_biu[2] && !$window_biu[2].disposed? && $window_biu[2].x > 0 && $window_biu[1].update?
  82.       end
  83.       #--------------------------------------------------------------------------
  84.       # ● 结束
  85.       #--------------------------------------------------------------------------
  86.       def self.over
  87.         $window_biu[0].over
  88.         $window_biu[1].over
  89.         $window_biu[2].over
  90.       end
  91.       #--------------------------------------------------------------------------
  92.       # ● 弹幕列表
  93.       #   (index, 内容)
  94.       #   index: 随便写,主要是为了当弹幕多的时候,可以分清需要哪一个。我建议每个10个空一行什么的
  95.       #--------------------------------------------------------------------------
  96.       def self.biulist(index)
  97.         @biu_list = [
  98.           [0, "为啥小优最\\{萌\\}"], # 前面要加逗号
  99.           [1, "\\C[6]Yoooooooooooooooooo~"] # 最后一行可以不加逗号
  100.         ]
  101.         index < @biu_list.size ? temp = index : temp = @biu_list.size
  102.         return @biu_list[temp][1]
  103.       end
  104.     end
  105.     #==============================================================================
  106.     # ■ Window_Biu
  107.     #------------------------------------------------------------------------------
  108.     #  显示弹幕的窗口
  109.     #==============================================================================
  110.     class Window_Biu < Window_Base
  111.       #----------------------------------------------------------------------------
  112.       # ● 初始化
  113.       #----------------------------------------------------------------------------
  114.       def initialize(speed)
  115.         @update = false
  116.         @over = false
  117.         @speed = speed
  118.                     super(0, 0, 2 * Graphics.width, Graphics.height)
  119.         self.opacity = 0
  120.         self.x = Graphics.width
  121.         self.z = 1000
  122.         create_contents
  123.       end
  124.       #--------------------------------------------------------------------------
  125.       # ● 获取标准的边距尺寸
  126.       #--------------------------------------------------------------------------
  127.       def standard_padding
  128.         return 0
  129.       end
  130.       #--------------------------------------------------------------------------
  131.       # ● 更新?
  132.       #--------------------------------------------------------------------------
  133.       def update?
  134.         @update
  135.       end
  136.       #--------------------------------------------------------------------------
  137.       # ● 更新内容
  138.       #--------------------------------------------------------------------------
  139.       def update
  140.         super
  141.         self.x -= @speed
  142.         if self.x <= 0
  143.           @update = true
  144.         end
  145.         if self.x <= (0 - (2 * Graphics.width))
  146.           self.x = Graphics.width
  147.           clear
  148.           if @over
  149.             close
  150.           end
  151.         end
  152.       end
  153.       #--------------------------------------------------------------------------
  154.       # ● 清除
  155.       #--------------------------------------------------------------------------
  156.       def clear
  157.         contents.clear
  158.       end
  159.       #--------------------------------------------------------------------------
  160.       # ● 增加内容
  161.       #--------------------------------------------------------------------------
  162.       def add(text, y)
  163.         draw_text_ex(Graphics.width - self.x, y, text)
  164.       end
  165.       #--------------------------------------------------------------------------
  166.       # ● 结束
  167.       #--------------------------------------------------------------------------
  168.       def over
  169.         @over = true
  170.       end
  171.       #--------------------------------------------------------------------------
  172.       # ● 关闭
  173.       #--------------------------------------------------------------------------
  174.       def close
  175.         self.dispose
  176.         @over = false
  177.       end
  178.      
  179.     end
  180.      
  181.     class Scene_Base
  182.       #--------------------------------------------------------------------------
  183.       # ● 更新画面
  184.       #--------------------------------------------------------------------------
  185.       alias old_update update
  186.       def update
  187.         old_update
  188.         if $window_biu
  189.           $window_biu[0].update if $window_biu[0] && !$window_biu[0].disposed?
  190.           $window_biu[1].update if $window_biu[1] && $window_biu[0].update? && !$window_biu[1].disposed?
  191.           $window_biu[2].update if $window_biu[2] && $window_biu[1].update? && !$window_biu[2].disposed?
  192.         end
  193.       end
  194.      
  195.     end
复制代码

那为什么下方这个脚本不能在77-78行或81-82行间插句self.dispose if @show_count == 0呢,
插了的话, 123号变量为1时, 会在场所移动后一两秒(应该是@show_count == 0)时报错disposed window
  1. # encoding: utf-8
  2. #==============================================================================
  3. # ** Window_MapNamePlus
  4. #------------------------------------------------------------------------------
  5. #  This window displays the map name.
  6. #------------------------------------------------------------------------------
  7. #  使用方法:
  8. #    新建脚本页,复制粘贴
  9. #    在“Scene_Map”中找到“Window_MapName.new”,改成"Window_MapNamePlus.new"(大概在
  10. #     159行左右)
  11. #    在地图属性的设置窗口,“显示名称”中的地图名格式:“中文名@EnglishName”,即用“@”分割中文
  12. #     和英文地图名
  13. #==============================================================================

  14. class Window_MapNamePlus < Window_Base
  15.   #--------------------------------------------------------------------------
  16.   # * Settings
  17.   #--------------------------------------------------------------------------
  18.   FONT_NAME_CH = ["PMingLiU", "FangSong"]       # Chinese Font Name
  19.   FONT_SIZE_CH = 42                             # Chinese Font Size
  20.   FONT_NAME_EN = ["Monotype Corsiva"]           # English Font Name
  21.   FONT_SIZE_EN = 28                             # English Font Size
  22.   FONT_BOLD    = false                          # True if Font in Bold
  23.   FONT_COLOR   = Color.new(255, 255, 255, 255)  # Color of Font
  24.   FONT_OUT     = true                           # True if Font Has Outline
  25.   OUT_COLOR    = Color.new(0, 0, 0, 200)        # Color of Outline Color of Font
  26.   FONT_SHADOW  = false                          # True if Text Drops Shadow
  27.   MODIFIER     = "~"                            # Modifier Added beside Map Name
  28.   PADDING      = 8                              # Padding between Window's Frame and Contents
  29.   LINE_HEIGHT  = 6                              # Height of Split Line
  30.   #--------------------------------------------------------------------------
  31.   # * Public Instance Variables
  32.   #--------------------------------------------------------------------------
  33.   attr_reader :map_name_ch                      # Chinese Map Name
  34.   attr_reader :map_name_en                      # English Map Name
  35.   attr_reader :line_x                           # Split Line X Coordinate
  36.   attr_reader :line_y                           # Split Line Y Coordinate
  37.   #--------------------------------------------------------------------------
  38.   # * Object Initialization
  39.   #--------------------------------------------------------------------------
  40.   def initialize
  41.     #----------------------------------------------------------------------
  42.     # * Set the window in the middle of screen.
  43.     #----------------------------------------------------------------------
  44.     super(((Graphics.width - window_width) / 2),
  45.       ((Graphics.height - (FONT_SIZE_CH + FONT_SIZE_EN + PADDING * 4 + LINE_HEIGHT)) / 2),
  46.       window_width, FONT_SIZE_CH + FONT_SIZE_EN + PADDING * 4 + LINE_HEIGHT)
  47.     #----------------------------------------------------------------------
  48.     # * Custom font and style.
  49.     #----------------------------------------------------------------------
  50.     contents.font.bold      = FONT_BOLD
  51.     contents.font.color     = FONT_COLOR
  52.     contents.font.outline   = FONT_OUT
  53.     contents.font.out_color = OUT_COLOR
  54.     contents.font.shadow    = FONT_SHADOW
  55.     #----------------------------------------------------------------------
  56.     # * Set Window Opacity
  57.     #----------------------------------------------------------------------
  58.     self.opacity = 0
  59.     self.contents_opacity = 0
  60.     @show_count = 0
  61.     refresh
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # * Get Window Width
  65.   #--------------------------------------------------------------------------
  66.   def window_width
  67.     return Graphics.width
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * Frame Update
  71.   #--------------------------------------------------------------------------
  72.   def update
  73.     super
  74.     if @show_count > 0 && $game_map.name_display
  75.       update_fadein
  76.       @show_count -= 1
  77.     else
  78.       update_fadeout
  79.     end
  80.     @show_count = 0 unless $game_map.name_display##########
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # * Update Fadein
  84.   #--------------------------------------------------------------------------
  85.   def update_fadein
  86.     self.contents_opacity += 16
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # * Update Fadeout
  90.   #--------------------------------------------------------------------------
  91.   def update_fadeout
  92.     self.contents_opacity -= 16
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # * Open Window
  96.   #--------------------------------------------------------------------------
  97.   def open
  98.     refresh
  99.     @show_count = 150
  100.     self.contents_opacity = 0
  101.     self
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # * Close Window
  105.   #--------------------------------------------------------------------------
  106.   def close
  107.     @show_count = 0
  108.     self
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # * Refresh
  112.   #--------------------------------------------------------------------------
  113.   def refresh
  114.     contents.clear
  115.     set_map_name
  116.     unless $game_map.display_name.empty?
  117.       draw_map_name
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # * Draw Line
  122.   #--------------------------------------------------------------------------
  123.   def draw_line(rect)
  124.     temp_rect = rect.clone
  125.     temp_rect.height = LINE_HEIGHT
  126.     temp_rect.width /= 4
  127.     contents.gradient_fill_rect(temp_rect, color2, color1)
  128.     temp_rect.x += temp_rect.width
  129.     temp_rect.width *= 2
  130.     contents.fill_rect(temp_rect, color1)
  131.     temp_rect.x += temp_rect.width
  132.     temp_rect.width /= 2
  133.     contents.gradient_fill_rect(temp_rect, color1, color2)
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * Set Map Name
  137.   #--------------------------------------------------------------------------
  138.   def set_map_name
  139. #~     temp_map_name = $game_map.display_name.split("@")
  140. #~     @map_name_ch  = temp_map_name[0].to_s
  141. #~     @map_name_en  = MODIFIER + " " + temp_map_name[1].to_s + " " + MODIFIER
  142.     ##########
  143.     @map_name_ch  = nil ; @map_name_en  = nil
  144.     $game_map.note.scan(/<第一行:(.*)>/){|matched|@map_name_cn = matched[0]}
  145.     @map_name_ch  = @map_name_cn || $game_map.display_name
  146.     $game_map.note.scan(/<第二行:(.*)>/){|matched|@map_name_en = matched[0]}
  147.     @map_name_en  = MODIFIER + " " + (@map_name_en || "作者未填写地图简介") + " " + MODIFIER
  148.     ##########
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # * Draw Map Name
  152.   #--------------------------------------------------------------------------
  153.   def draw_map_name
  154.     set_line_position
  155.     set_line_width
  156.     temp_line_rect = Rect.new(@line_x, @line_y, set_line_width, LINE_HEIGHT)
  157.     draw_line(temp_line_rect)
  158.     temp_name_rect_ch = Rect.new(0, 0, contents.width, FONT_SIZE_CH)
  159.     contents.font.name = FONT_NAME_CH
  160.     contents.font.size = FONT_SIZE_CH
  161.     draw_text(temp_name_rect_ch, @map_name_ch, 1)
  162.     temp_name_rect_en = Rect.new(0, FONT_SIZE_CH, contents.width, FONT_SIZE_EN)
  163.     contents.font.size = FONT_SIZE_EN
  164.     contents.font.name = FONT_NAME_EN
  165.     draw_text(temp_name_rect_en, @map_name_en, 1)
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # * Set Line Width
  169.   #--------------------------------------------------------------------------
  170.   def set_line_width
  171.     text_width_ch = text_size(@map_name_ch).width * 1.5
  172.     text_width_en = text_size(@map_name_en).width * 1.5
  173.     (text_width_ch >= text_width_en) ?
  174.       (text_width_ch) : (text_width_en)
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * Set Line Position
  178.   #--------------------------------------------------------------------------
  179.   def set_line_position
  180.     @line_x = (contents.width - set_line_width) / 2
  181.     @line_y = (contents.height - LINE_HEIGHT) / 2
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # * Get Color 1
  185.   #--------------------------------------------------------------------------
  186.   def color1
  187.     Color.new(255, 255, 255, 255)
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # * Get Color 2
  191.   #--------------------------------------------------------------------------
  192.   def color2
  193.     Color.new(255, 255, 255, 0)
  194.   end
  195. end

  196. ##########
  197. module MAPNAMEPLUS
  198.   VAR_ID = 123##########變量
  199. end

  200. #==============================================================================
  201. # ** Game_Map
  202. #------------------------------------------------------------------------------
  203. #  This class handles maps. It includes scrolling and passage determination
  204. # functions. The instance of this class is referenced by $game_map.
  205. #==============================================================================

  206. class Game_Map
  207.   #--------------------------------------------------------------------------
  208.   # * New method: note
  209.   #--------------------------------------------------------------------------
  210.   def note
  211.     @map ? @map.note : ""
  212.   end
  213. end

  214. #encoding:utf-8
  215. #==============================================================================
  216. # ■ Window_MapName
  217. #------------------------------------------------------------------------------
  218. #  顯示地圖名稱的窗口。
  219. #==============================================================================

  220. class Window_MapName < Window_Base
  221.   #--------------------------------------------------------------------------
  222.   # ● 打開窗口
  223.   #--------------------------------------------------------------------------
  224.   alias :window_mapname_open_map_name_plus :open
  225.   def open
  226.     return if $game_variables[MAPNAMEPLUS::VAR_ID] >= 2
  227.     window_mapname_open_map_name_plus
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● 關閉窗口
  231.   #--------------------------------------------------------------------------
  232.   alias :window_mapname_close_map_name_plus :close
  233.   def close
  234.     return if $game_variables[MAPNAMEPLUS::VAR_ID] >= 2
  235.     window_mapname_close_map_name_plus
  236.   end
  237. end

  238. #encoding:utf-8
  239. #==============================================================================
  240. # ■ Scene_Map
  241. #------------------------------------------------------------------------------
  242. #  地圖畫面
  243. #==============================================================================

  244. class Scene_Map < Scene_Base
  245.   #--------------------------------------------------------------------------
  246.   # ● 結束前處理
  247.   #--------------------------------------------------------------------------
  248.   alias :scene_map_pre_terminate_map_name_plus :pre_terminate
  249.   def pre_terminate
  250.     scene_map_pre_terminate_map_name_plus
  251.     @map_name_plus_window.dispose if @map_name_plus_window && !@map_name_plus_window.disposed?
  252.     @map_name_plus_window = nil
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 場所移動前的處理
  256.   #--------------------------------------------------------------------------
  257.   alias :scene_map_pre_transfer_map_name_plus :pre_transfer
  258.   def pre_transfer
  259.     @map_name_plus_window.close if @map_name_plus_window
  260.     scene_map_pre_transfer_map_name_plus
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● 場所移動后的處理
  264.   #--------------------------------------------------------------------------
  265.   alias :scene_map_post_transfer_map_name_plus :post_transfer
  266.   def post_transfer
  267.     scene_map_post_transfer_map_name_plus
  268.     var_value = $game_variables[MAPNAMEPLUS::VAR_ID]
  269.     case var_value
  270.     when 1, 2
  271.       @map_name_plus_window = Window_MapNamePlus.new unless @map_name_plus_window
  272.     end
  273.     @map_name_plus_window.open if @map_name_plus_window
  274.   end
  275. end
  276. ##########
复制代码

最佳答案

查看完整内容

不好意思,其实我忘了看第二个脚本( 你这个窗口是绑定在Scene里面的一个实例变量,不需要自己释放了 因为Scene_Base里面会统一更新、释放是窗口的实例变量 具体可以看类里面的 dispose_windows 这是一种元编程模式,默认的那些窗口也都没有再写额外的更新和释放 以及如果只是单纯想让它不再显示,推荐用 window 类继承下来的 hide 和 show 方法 如果想刷新内容,推荐不要用生成、释放的模式,而是用它的 refresh ...

老鹰

梦石
40
星屑
38044
在线时间
7127 小时
注册时间
2012-5-26
回帖
3306

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2021-3-9 10:40:46 | 显示全部楼层
本帖最后由 百里_飞柳 于 2021-3-9 12:59 编辑
alexncf125 发表于 2021-3-9 11:43
============================================================

这句是指, 在Scene_Map的def update內加 ...


不好意思,其实我忘了看第二个脚本(

你这个窗口是绑定在Scene里面的一个实例变量,不需要自己释放了
因为Scene_Base里面会统一更新、释放是窗口的实例变量
具体可以看类里面的 dispose_windows

这是一种元编程模式,默认的那些窗口也都没有再写额外的更新和释放

以及如果只是单纯想让它不再显示,推荐用 window 类继承下来的 hide 和 show 方法
如果想刷新内容,推荐不要用生成、释放的模式,而是用它的 refresh
回复

使用道具 举报

老鹰

梦石
40
星屑
38044
在线时间
7127 小时
注册时间
2012-5-26
回帖
3306

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2021-3-9 11:18:02 | 显示全部楼层
这个弹幕脚本吓到我了,怎会有如此暴力的直接指定只能生成三个数目的更新方式(

因为它在窗口更新前判断了下窗口是否被释放
如果被释放了,就不再更新,因此没有报错,即189行
  1. $window_biu[0].update if $window_biu[0] && !$window_biu[0].disposed?
复制代码


你也可以在你的窗口的update前面判断下是否被释放
要么在
  1. window.update if !window.disposed?
复制代码

要么在
  1. def update
  2.   return if disposed?
  3.   super
  4. end
复制代码

回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 2021-3-9 11:43:36 | 显示全部楼层
本帖最后由 alexncf125 于 2021-3-9 11:45 编辑
百里_飞柳 发表于 2021-3-9 11:18
这个弹幕脚本吓到我了,怎会有如此暴力的直接指定只能生成三个数目的更新方式(

因为它在窗口更新前判断了 ...

============================================================
window.update if !window.disposed?

这句是指, 在Scene_Map的def update內加句
@map_name_plus_window.update if !@map_name_plus_window.disposed?么
好像没效喔
============================================================
    def update
      return if disposed?
      super
    end

这段是指, 把Window_MapNamePlus的def update改成这样子么
  1.   def update
  2.     return if disposed?##########
  3.     super
  4.     if @show_count > 0 && $game_map.name_display
  5.       update_fadein
  6.       @show_count -= 1
  7.       self.dispose if @show_count == 0##########
  8.     else
  9.       update_fadeout
  10.     end
  11.     @show_count = 0 unless $game_map.name_display##########
  12.   end
复制代码


不过这样子改会变成117行报错disposed window喔
如果在117行前加句return if disposed?又会到103行报错
难不成是得在每个方法前都得return if disposed?
回复

使用道具 举报

梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2021-3-9 12:27:28 | 显示全部楼层
77-78

  1. self.dispose if @map_name_plus_window
复制代码
回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 2021-3-9 12:37:03 | 显示全部楼层
soulsaga 发表于 2021-3-9 12:27
77-78

self.dispose if @map_name_plus_window[/pre]


別开玩笑吧....
77-78行的位置在class Window_MapNamePlus, 哪有@map_name_plus_window
@map_name_plus_window是class Scene_Map中, Window_MapNamePlus的实例

点评

哦..没留意..  发表于 2021-3-9 13:29
回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 2021-3-9 13:17:36 | 显示全部楼层
百里_飞柳 发表于 2021-3-9 12:57
不好意思,其实我忘了看第二个脚本(

你这个窗口是绑定在Scene里面的一个实例变量,不需要自己释放了


好吧...总括而言,
即是不能在class Window_MapNamePlus的def update写self.dispose
只能在class Scene_Map的def update写@map_name_plus_window.dispose
就是这样没错吧...那我还是乖乖去Scene_Map写好了...谢谢大佬

点评

因为scene会自动更新它里面的全部窗口,即 @window_xxx 这样形式的变量,如果是窗口类的对象,它自动帮你更新、释放,所以你再释放,就会出现报错  发表于 2021-3-9 14:06
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部