Project1

标题: 复杂装备系统地图显示问题 [打印本页]

作者: 上贺茂润    时间: 2013-10-22 17:42
标题: 复杂装备系统地图显示问题
本帖最后由 上贺茂润 于 2013-10-22 19:19 编辑
  1. #==============================================================================
  2. # ■ Window_MapName
  3. #==============================================================================

  4. class Window_MapName < Window_Base
  5. #--------------------------------------------------------------------------
  6. # ● 初始化
  7. #--------------------------------------------------------------------------
  8. def initialize
  9.    @map_id = $game_map.map_id
  10.    super(0, 0, 182, 52)
  11.    self.contents.font.size = 20
  12.    self.z = 151
  13.    refresh
  14. end
  15. #--------------------------------------------------------------------------
  16. # ● 刷新
  17. #--------------------------------------------------------------------------
  18. def refresh
  19.    self.opacity = 255
  20.    self.contents_opacity = 255
  21.    name = $data_mapinfos[@map_id].name
  22.    width = self.contents.text_size(name).width
  23.    height = self.contents.text_size(name).height
  24.    self.width = width + 32
  25.    self.height = height + 32
  26.    self.contents = Bitmap.new(width, height)
  27.    self.contents.font.size = 20
  28.    self.x = 0
  29.    self.y = 0
  30.    self.contents.font.color = system_color
  31.    self.contents.draw_text(0, 0, width, 20, name, 1)
  32. end
  33. #--------------------------------------------------------------------------
  34. # ● 更新
  35. #--------------------------------------------------------------------------
  36. def update
  37.    if $game_map.map_id != @map_id
  38.      @map_id = $game_map.map_id
  39.      refresh
  40.      self.opacity -= 5
  41.      self.contents_opacity = 255
  42.    end
  43.    refresh if $game_map.map_id == 388
  44.    return if self.opacity == 0
  45.    self.opacity = 255                       #原来是-=5
  46.    self.contents_opacity = 255              #原来是-=5
  47. end

  48. end

  49. class Scene_Title < Scene_Base
  50. #--------------------------------------------------------------------------
  51. # ● 数据库载入
  52. #--------------------------------------------------------------------------
  53. alias old_ld load_database
  54. def load_database
  55.    old_ld
  56.    $data_mapinfos       = load_data("Data/MapInfos.rvdata")
  57. end
  58. end

  59. class Scene_Map < Scene_Base
  60. #--------------------------------------------------------------------------
  61. # ● 开始
  62. #--------------------------------------------------------------------------
  63. alias old_start start
  64. def start
  65.    old_start
  66.    @mapname_window = Window_MapName.new
  67. end
  68. #--------------------------------------------------------------------------
  69. # ● 结束
  70. #--------------------------------------------------------------------------
  71. alias old_ter terminate
  72. def terminate
  73.    old_ter
  74.    @mapname_window.dispose
  75. end
  76. #--------------------------------------------------------------------------
  77. # ● 更新
  78. #--------------------------------------------------------------------------
  79. alias old_update update
  80. def update
  81.    old_update
  82.    @mapname_window.update
  83. end
  84. end
复制代码
总所周知,复杂装备系统有地名显示功能,但是都是一直显示的,请教一下如何加一个开关来控制地名的显示。

作者: 铃仙·优昙华院·因幡    时间: 2013-10-22 18:23
RUBY 代码复制
  1. class Window_MapName < Window_Base
  2. #--------------------------------------------------------------------------
  3. # ● 刷新
  4. #--------------------------------------------------------------------------
  5. def refresh
  6.    return if $game_switches[1]        # 1号开关打开时候不显示
  7.    self.opacity = 255
  8.    self.contents_opacity = 255
  9.    name = $data_mapinfos[@map_id].name
  10.    width = self.contents.text_size(name).width
  11.    height = self.contents.text_size(name).height
  12.    self.width = width + 32
  13.    self.height = height + 32
  14.    self.contents = Bitmap.new(width, height)
  15.    self.contents.font.size = 20
  16.    self.x = 0
  17.    self.y = 0
  18.    self.contents.font.color = system_color
  19.    self.contents.draw_text(0, 0, width, 20, name, 1)
  20. end

作者: 上贺茂润    时间: 2013-10-22 18:55
铃仙·优昙华院·因幡 发表于 2013-10-22 18:23
class Window_MapName < Window_Base
#-------------------------------------------------------------- ...


字是没了,框还在……我把每一个过程都加一个return 开关后就报错了……
作者: 铃仙·优昙华院·因幡    时间: 2013-10-22 19:09
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2. # ● 更新
  3. #--------------------------------------------------------------------------
  4. def update
  5.    if $game_switches[1]
  6.        self.opacity = 0
  7.        return
  8.    end
  9.    if $game_map.map_id != @map_id
  10.      @map_id = $game_map.map_id
  11.      refresh
  12.      self.opacity -= 5
  13.      self.contents_opacity = 255
  14.    end
  15.    refresh if $game_map.map_id == 388
  16.    return if self.opacity == 0
  17.    self.opacity = 255                       #原来是-=5
  18.    self.contents_opacity = 255              #原来是-=5
  19. end


改错地方了 = =




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1