Project1

标题: 如何在指定位置显示指定的数据 [打印本页]

作者: singlewalker    时间: 2019-9-23 18:08
标题: 如何在指定位置显示指定的数据
例如我想在不按esc的情况下 在画面的右上方显示金币的数量经验值一类的
作者: KB.Driver    时间: 2019-9-28 14:54
本帖最后由 KB.Driver 于 2019-9-28 14:55 编辑



RUBY 代码复制
  1. #encoding:utf-8
  2. module CLD99
  3.   module GOLD_AND_EXP_WINDOW_ON_MAP
  4.     class << self
  5.       attr_accessor :need_refresh
  6.     end
  7.     GOLD_WINDOW_WIDTH = 240
  8.     EXP_WINDOW_WIDTH  = 240
  9.   end
  10. end
  11.  
  12. class Scene_Map < Scene_Base
  13.   #--------------------------------------------------------------------------
  14.   # ● 生成所有窗口
  15.   #--------------------------------------------------------------------------
  16.   alias create_all_windows_for_gold_and_exp_window create_all_windows
  17.   def create_all_windows
  18.     create_all_windows_for_gold_and_exp_window
  19.     create_gold_window
  20.     create_exp_window
  21.   end
  22.  
  23.   def create_gold_window
  24.     @gold_window = (Class.new(Window_Gold) do
  25.       def window_width
  26.         CLD99::GOLD_AND_EXP_WINDOW_ON_MAP::GOLD_WINDOW_WIDTH
  27.       end
  28.     end).new
  29.     @gold_window.x = Graphics.width - @gold_window.width
  30.   end
  31.  
  32.   def create_exp_window
  33.     w = CLD99::GOLD_AND_EXP_WINDOW_ON_MAP::EXP_WINDOW_WIDTH
  34.     h = $game_party.battle_members.size * 33 + 24
  35.     x = Graphics.width - w
  36.     y = @gold_window.height
  37.     @exp_window = Window_Base.new(x, y, w, h)
  38.     $game_party.battle_members.each_with_index do |actor, i|
  39.       x, y = 12, 12 + i * 33
  40.       name, index = actor.character_name, actor.character_index
  41.       @exp_window.draw_character(name, index, x, y + 20)
  42.       text = "Exp. #{actor.exp}/#{actor.next_level_exp}"
  43.       @exp_window.draw_text(x + 20, y - 8, w - 24, 24, text)
  44.     end
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● 更新画面
  48.   #--------------------------------------------------------------------------
  49.   alias update_for_gold_and_exp_window update
  50.   def update
  51.     if CLD99::GOLD_AND_EXP_WINDOW_ON_MAP.need_refresh || $game_map.need_refresh
  52.       @gold_window.refresh
  53.       @exp_window.dispose
  54.       create_exp_window
  55.       CLD99::GOLD_AND_EXP_WINDOW_ON_MAP.need_refresh = false
  56.     end
  57.     update_for_gold_and_exp_window
  58.   end
  59. end
  60.  
  61. class Game_Interpreter
  62.   #--------------------------------------------------------------------------
  63.   # ● 增减经验值
  64.   #--------------------------------------------------------------------------
  65.   alias command_315_for_gold_and_exp_window command_315
  66.   def command_315
  67.     command_315_for_gold_and_exp_window
  68.     CLD99::GOLD_AND_EXP_WINDOW_ON_MAP.need_refresh = true
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 增减持有金钱
  72.   #--------------------------------------------------------------------------
  73.   alias command_125_for_gold_and_exp_window command_125
  74.   def command_125
  75.     command_125_for_gold_and_exp_window
  76.     CLD99::GOLD_AND_EXP_WINDOW_ON_MAP.need_refresh = true
  77.   end
  78. end

作者: singlewalker    时间: 2019-9-30 01:38
KB.Driver 发表于 2019-9-28 14:54
#encoding:utf-8
module CLD99
  module GOLD_AND_EXP_WINDOW_ON_MAP

为什么一但切换地图就会出现
脚本“scene_Map"第211行发生nomethodError.
uddefined method 'close' for nil:NilClass
作者: singlewalker    时间: 2019-9-30 13:13
singlewalker 发表于 2019-9-30 01:38
为什么一但切换地图就会出现
脚本“scene_Map"第211行发生nomethodError.
uddefined method 'close' for  ...

没有,在新档测试了两次也这样
作者: singlewalker    时间: 2019-9-30 13:20
顺便一问,能否做到只在地图AB中执行该脚本而不再C地图中执行呢?????




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