Project1

标题: 这个代码怎么改地图名字显示的时间? [打印本页]

作者: a604682925    时间: 2008-7-3 02:06
提示: 作者被禁止或删除 内容自动屏蔽
作者: 浪使者    时间: 2008-7-3 04:17
它是通过渐进改变透明度来控制窗体显示的时间。。

永久显示地图名的代码: (直接覆盖原代码即可)
  1. #================================================
  2. # ■ Window_Pos
  3. #================================================

  4. class Window_Pos < Window_Base
  5. #------------------------------------------------
  6. # ● 初始化
  7. #------------------------------------------------
  8. def initialize
  9.   super(0, 0, 122, 52)
  10.   self.z = 151
  11.   self.contents.font.size = 20
  12.   refresh
  13. end
  14. #------------------------------------------------
  15. # ● 刷新
  16. #------------------------------------------------
  17. def refresh
  18.   self.contents.clear
  19.   self.contents.font.color = system_color
  20.   @x,@y = $game_player.x,$game_player.y
  21.   self.contents.draw_text(0, 0, 90, 20, "(#{@x},#{@y})", 1)
  22. end
  23. #------------------------------------------------
  24. # ● 更新
  25. #------------------------------------------------
  26. def update
  27.   return if $game_player.x == @x and $game_player.y == @y
  28.   refresh
  29. end
  30. end

  31. #================================================
  32. # ■ Window_MapName
  33. #================================================

  34. class Window_MapName < Window_Base
  35. #------------------------------------------------
  36. # ● 初始化
  37. #------------------------------------------------
  38. def initialize
  39.   @map_id = $game_map.map_id
  40.   super(0, 0, 182, 52)
  41.   self.contents.font.size = 20
  42.   self.z = 151
  43.   refresh
  44. end
  45. #------------------------------------------------
  46. # ● 刷新
  47. #------------------------------------------------
  48. def refresh
  49.   self.opacity = 255
  50.   self.contents_opacity = 255
  51.   name = $data_mapinfos[@map_id].name
  52.   width = self.contents.text_size(name).width
  53.   height = self.contents.text_size(name).height
  54.   self.width = width + 32
  55.   self.height = height + 32
  56.   self.contents = Bitmap.new(width, height)
  57.   self.contents.font.size = 20
  58.   self.x = (Graphics.width - self.width) / 2
  59.   self.y = (Graphics.height - self.height) / 2
  60.   self.contents.font.color = system_color
  61.   self.contents.draw_text(0, 0, width, 20, name, 1)
  62. end
  63. #------------------------------------------------
  64. # ● 更新
  65. #------------------------------------------------
  66. def update
  67.   if $game_map.map_id != @map_id
  68.     @map_id = $game_map.map_id
  69.     refresh
  70.     self.opacity = 255
  71.     self.contents_opacity = 255
  72.   end
  73.   return if self.opacity == 0
  74.   self.opacity -= 0
  75.   self.contents_opacity -= 0
  76. end

  77. end

  78. class Scene_Title < Scene_Base
  79. #------------------------------------------------
  80. # ● 数据库载入
  81. #------------------------------------------------
  82. alias old_ld load_database
  83. def load_database
  84.   old_ld
  85.   $data_mapinfos       = load_data("Data/MapInfos.rvdata")
  86. end
  87. end

  88. class Scene_Map < Scene_Base
  89. #------------------------------------------------
  90. # ● 开始
  91. #------------------------------------------------
  92. alias old_start start
  93. def start
  94.   old_start
  95.   @pos_window = Window_Pos.new
  96.   @mapname_window = Window_MapName.new
  97. end
  98. #------------------------------------------------
  99. # ● 结束
  100. #------------------------------------------------
  101. alias old_ter terminate
  102. def terminate
  103.   old_ter
  104.   @pos_window.dispose
  105.   @mapname_window.dispose
  106. end
  107. #------------------------------------------------
  108. # ● 更新
  109. #------------------------------------------------
  110. alias old_update update
  111. def update
  112.   old_update
  113.   @pos_window.update
  114.   @mapname_window.update
  115. end
  116. end
复制代码


减慢消失地图名的代码:(同样直接覆盖)
  1. #================================================
  2. # ■ Window_Pos
  3. #================================================

  4. class Window_Pos < Window_Base
  5. #------------------------------------------------
  6. # ● 初始化
  7. #------------------------------------------------
  8. def initialize
  9.   super(0, 0, 122, 52)
  10.   self.z = 151
  11.   self.contents.font.size = 20
  12.   refresh
  13. end
  14. #------------------------------------------------
  15. # ● 刷新
  16. #------------------------------------------------
  17. def refresh
  18.   self.contents.clear
  19.   self.contents.font.color = system_color
  20.   @x,@y = $game_player.x,$game_player.y
  21.   self.contents.draw_text(0, 0, 90, 20, "(#{@x},#{@y})", 1)
  22. end
  23. #------------------------------------------------
  24. # ● 更新
  25. #------------------------------------------------
  26. def update
  27.   return if $game_player.x == @x and $game_player.y == @y
  28.   refresh
  29. end
  30. end

  31. #================================================
  32. # ■ Window_MapName
  33. #================================================

  34. class Window_MapName < Window_Base
  35. #------------------------------------------------
  36. # ● 初始化
  37. #------------------------------------------------
  38. def initialize
  39.   @map_id = $game_map.map_id
  40.   super(0, 0, 182, 52)
  41.   self.contents.font.size = 20
  42.   self.z = 151
  43.   refresh
  44. end
  45. #------------------------------------------------
  46. # ● 刷新
  47. #------------------------------------------------
  48. def refresh
  49.   self.opacity = 255
  50.   self.contents_opacity = 255
  51.   name = $data_mapinfos[@map_id].name
  52.   width = self.contents.text_size(name).width
  53.   height = self.contents.text_size(name).height
  54.   self.width = width + 32
  55.   self.height = height + 32
  56.   self.contents = Bitmap.new(width, height)
  57.   self.contents.font.size = 20
  58.   self.x = (Graphics.width - self.width) / 2
  59.   self.y = (Graphics.height - self.height) / 2
  60.   self.contents.font.color = system_color
  61.   self.contents.draw_text(0, 0, width, 20, name, 1)
  62. end
  63. #------------------------------------------------
  64. # ● 更新
  65. #------------------------------------------------
  66. def update
  67.   if $game_map.map_id != @map_id
  68.     @map_id = $game_map.map_id
  69.     refresh
  70.     self.opacity = 255
  71.     self.contents_opacity = 255
  72.   end
  73.   return if self.opacity == 0
  74.   self.opacity -= 1
  75.   self.contents_opacity -= 1
  76. end

  77. end

  78. class Scene_Title < Scene_Base
  79. #------------------------------------------------
  80. # ● 数据库载入
  81. #------------------------------------------------
  82. alias old_ld load_database
  83. def load_database
  84.   old_ld
  85.   $data_mapinfos       = load_data("Data/MapInfos.rvdata")
  86. end
  87. end

  88. class Scene_Map < Scene_Base
  89. #------------------------------------------------
  90. # ● 开始
  91. #------------------------------------------------
  92. alias old_start start
  93. def start
  94.   old_start
  95.   @pos_window = Window_Pos.new
  96.   @mapname_window = Window_MapName.new
  97. end
  98. #------------------------------------------------
  99. # ● 结束
  100. #------------------------------------------------
  101. alias old_ter terminate
  102. def terminate
  103.   old_ter
  104.   @pos_window.dispose
  105.   @mapname_window.dispose
  106. end
  107. #------------------------------------------------
  108. # ● 更新
  109. #------------------------------------------------
  110. alias old_update update
  111. def update
  112.   old_update
  113.   @pos_window.update
  114.   @mapname_window.update
  115. end
  116. end
复制代码
[LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: a604682925    时间: 2008-7-3 07:35
提示: 作者被禁止或删除 内容自动屏蔽
作者: 浪使者    时间: 2008-7-3 21:13
可以,你重新发个新帖吧。。
写清楚你是要把“地图名显示”的位置放到坐标位置,替换掉坐标,只显示地图名,
还是在原显示坐标的位置,把“地图名显示”和坐标显示放到一块里。。




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