Project1

标题: 如何把这个这个窗口调整位置 [打印本页]

作者: LOVE丶莫颜    时间: 2012-5-25 19:21
标题: 如何把这个这个窗口调整位置
不懂脚本表示很惭愧,只能麻烦大大们了。
↓如图↓

①:如何把“显示角色状态的窗口”调到靠最左边。
②:如何把“显示地图坐标和名称的窗口”调到最左边的“↑角色状态↑”的靠左边。
就是说让这两个窗口靠近,从而排在最左边(不重叠!)
状态脚本:

#################################################################
#地图界面的状态显示脚本(暴动冲锋NANKONGX/坂崎由丽NKX注释)
#本脚本来自66rpg.com,使用时请带上本信息。
#关于本脚本的使用:
# 本状态脚本是受开关控制的,默认开关编号为2,在脚本里可以修改。
# 一旦制定开关打开,在普通地图显示的状态下屏幕下方会显示主角状态。
#################################################################

#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  处理地图画面的类。
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # ● 在这里控制脚本的属性
  #--------------------------------------------------------------------------
  SWITCH_ID = 2 #在这里设定开关的编号……
  $center_hud = true  #这里决定是否将HUD(状态窗口)居中显示……
  #--------------------------------------------------------------------------
  # ● 初始化别名
  #--------------------------------------------------------------------------
  alias raz_hud_main main
  alias raz_hud_update update
  #--------------------------------------------------------------------------
  # ● 主进程
  #--------------------------------------------------------------------------  
  def main
    @size = $game_party.actors.size
    raz_hud_main
    @hud_window.dispose
    for i in 0...$game_party.actors.size
      @hud_dummy.dispose
    end #for
  end #def
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------  
  def update
    if @size != $game_party.actors.size
      @hud_window.refresh
      show_window
    end #if
    if @hud != true
      main_window
    end #if
    turn_hud_on_off
    @hud_window.update
    raz_hud_update
  end #def
  #--------------------------------------------------------------------------
  # ● 与状态窗口的显示行为相关的语句
  #--------------------------------------------------------------------------   
  def show_window
    @size = $game_party.actors.size
    for i in 0..3
      @hud_dummy.visible = ($game_party.actors != nil)
    end #for
  end #def
  #--------------------------------------------------------------------------
  # ● 与状态窗口的创建相关的语句
  #--------------------------------------------------------------------------     
  def main_window
    @opacity = 200
    @hud_dummy = []
    for i in 0...4
      y = $game_party.actors.size - 1
      x = 240 - (y * 80)
      if $center_hud == true
        @hud_dummy = Window_Base.new(160 * i + x, 372,160, 108)
      else
        @hud_dummy = Window_Base.new(160 * i, 372,160, 108)
      end #if
      @hud_dummy.opacity = @opacity
      @hud_dummy.visible = false
    end #for
    @hud_window = Window_HUD.new
    for i in 0...$game_party.actors.size
      @hud_dummy.visible = $game_party.actors != nil
    end #for
    @hud = true
  end #def
  #--------------------------------------------------------------------------
  # ● 与状态窗口的开关相关的语句
  #--------------------------------------------------------------------------   
  def turn_hud_on_off
   if $game_switches[SWITCH_ID] == false #关掉开关
    @hud_window.visible = false
      for i in 0...$game_party.actors.size
        @hud_dummy.visible = false
      end #for
    end #if
   if $game_switches[SWITCH_ID] == true #打开开关
     @hud_window.visible = true
     for i in 0...$game_party.actors.size
       @hud_dummy.visible = true
     end #for
   end #if
  end #def
end #class
#==============================================================================
# ■ Window_HUD
#------------------------------------------------------------------------------
#  地图画面中显示的状态窗口。
#==============================================================================
class Window_HUD < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 800, 600)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    for i in 0...$game_party.actors.size
      actor = $game_party.actors
      eval("@old_hp#{i+1} = actor.hp; @old_sp#{i+1} = actor.sp; @old_exp#{i+1} = actor.now_exp")
    end #for
    refresh
  end #def
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...$game_party.actors.size
      a = $game_party.actors.size - 1
      actor = $game_party.actors
      if $center_hud == true
       x = (i * 160 + 25) + (240 - (a * 80))
      else
       x = i * 160 + 25
      end #if
      self.contents.font.size = 21
      draw_actor_graphic(actor, x - 15, 445)
      self.contents.font.color = normal_color
      self.contents.draw_text(x - 25, 360, 100, 32, actor.name)
      width = 100
      height = 6
      draw_slant_bar(x + 8, 396, actor.hp, actor.maxhp, width, height, Color.new(150, 0, 0), Color.new(155, 155, 60))
      draw_slant_bar(x + 8, 416, actor.sp, actor.maxsp, width, height, Color.new(0, 0, 150), Color.new(60, 155, 155))
      unless actor.level == 99
        draw_slant_bar(x + 8, 436, actor.now_exp, actor.next_exp, width, height, Color.new(0, 150, 0), Color.new(60, 255, 60))
      else
        draw_slant_bar(x + 8, 436, 1, 1, width = 100, height = 6, Color.new(0, 150, 0), Color.new(60, 255, 60))
      end #unless
      self.contents.font.size = 16
      draw_actor_state(actor, x + 45, 360)
      self.contents.font.color = normal_color
      self.contents.font.bold = true
      self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
      self.contents.draw_text(x + 16, 382, 100, 32, "#{actor.hp}/#{actor.maxhp}", 1)
      self.contents.font.color = actor.sp == 0 ? crisis_color : actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
      self.contents.draw_text(x + 16, 402, 100, 32, "#{actor.sp}/#{actor.maxsp}", 1)
      self.contents.font.color = system_color
      self.contents.font.size = 20
      self.contents.font.bold = false
      self.contents.draw_text(x, 384, 50, 32, "HP") #HP的显示文本,可修改。
      self.contents.draw_text(x, 404, 50, 32, "MP") #SP的显示文本,可修改。
      self.contents.draw_text(x, 424, 50, 32, "Ene") #EXP的显示文本,可修改。
    end #for
  end #def
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    for i in 0...$game_party.actors.size
      actor = $game_party.actors
      if (eval("@old_hp#{i+1}") != actor.hp or eval("@old_sp#{i+1}") != actor.sp or
        eval("@old_exp#{i+1}") != actor.now_exp)
        refresh
        eval("@old_hp#{i+1} = actor.hp; @old_sp#{i+1} = actor.sp; @old_exp#{i+1} = actor.now_exp")
      end #if
    end #super
  end #def
end #class
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  游戏中全部窗口的超级类。
#==============================================================================
class Window_Base < Window
  #状态条的绘制
  def draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end #for
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end #for
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end #for
    end #for
  end #def
end #class
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  处理角色的类。本类在 Game_Actors 类 ($game_actors)
# 的内部使用、Game_Party 类请参考 ($game_party) 。
#==============================================================================
class Game_Actor
  #获取当前EXP
  def now_exp
    return @exp - @exp_list[@level]
  end #def
  #获取下一级需要EXP的数值
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end #def
end
#################################################################
#本脚本来自66rpg.com,使用时请带上本信息。
#################################################################



地图名称坐标脚本:
#==========================================================================
# 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。别以为加密就可以del哦
#==========================================================================
XY_SWITCH = 25 # 当25号开关打开,本脚本才开始工作。
#==============================================================================
# ■ Window_XY
#------------------------------------------------------------------------------
#  显示坐标的窗口。
#==============================================================================
class Window_xy < Window_Base#注意前面那个window_xy是文件名
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
   super(0, 0, 160, 96)#最后面那个数字是宽要显示多个需要改大,前面一个是长~
   self.contents = Bitmap.new(width - 32, height - 32)
   self.back_opacity = 255  # 这个是背景透明
   self.opacity = 255       # 这个是边框和背景都透明
   self.contents_opacity = 255       # 这个是内容透明
   self.visible = false
   refresh
   @x = $game_player.x
   @y = $game_player.y
   @id = $game_map.map_id
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
   if $game_switches[XY_SWITCH] #确定开关是否打开,可以自己改变开关
     @x = $game_player.x #获取角色X坐标
     @y = $game_player.y #获取角色Y坐标
     @id = $game_map.map_id  #获取地图编号
    self.contents.clear #清除以前的东西
    $mapnames = load_data("Data/MapInfos.rxdata") #读取地图名文件
    map_name = $mapnames[@id].name #获得地图名
    self.contents.font.color = normal_color#颜色,这里是白色~
    self.contents.draw_text(0, 0, 116, 32, map_name,2)
    self.contents.font.color = system_color#颜色,暗蓝色
    self.contents.draw_text(0, 32, 120, 32, "X:")#显示X这个字的位置,引号里面的内容随便改,比如"X坐标地址"
    self.contents.font.color = normal_color#颜色,这里是白色~
    self.contents.draw_text(0, 32, 52, 32, @x.to_s,2)
    self.contents.font.color = system_color#上面那个是X坐标的变量,可以自己更改变量名~
    self.contents.draw_text(64, 32, 128, 32, "Y:")#显示Y这个字~
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 32, 116, 32, @y.to_s,2)
   end
end
#--------------------------------------------------------------------------
# ● 判断文字刷新。节约内存用
#--------------------------------------------------------------------------
def judge
   return true if @x != $game_player.x
   return true if @y != $game_player.y
   return true if @id != $game_map.map_id
   return false
end
end
###########################################################################
#                           下面的东西不需要掌握~                         #
###########################################################################
class Scene_Map
alias xy_66rpg_main main
def main
   @xy_window = Window_xy.new
   @xy_window.x = 640 - 160
   @xy_window.y = 480 - 96
   @xy_window.opacity = 0
   xy_66rpg_main
   @xy_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias xy_66rpg_update update
def update
   xy_66rpg_update
   if $game_switches[XY_SWITCH]
     @xy_window.visible = true      
     @xy_window.refresh if @xy_window.judge
   else
     @xy_window.visible = false
   end
end
end
#==========================================================================
# 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。别以为加密就可以del哦
#==========================================================================dsu_plus_rewardpost_czw
作者: sai90306    时间: 2012-5-25 20:21
本帖最后由 sai90306 于 2012-5-26 01:00 编辑

狀態窗口...我找了元版的腳本改好true=false了  直接貼上覆蓋原來的就可以了
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Scene_Map
  3. #------------------------------------------------------------------------------
  4. #  处理地图画面的类。
  5. #==============================================================================
  6. class Scene_Map
  7.   #--------------------------------------------------------------------------
  8.   # ● 在这里控制脚本的属性
  9.   #--------------------------------------------------------------------------
  10.   SWITCH_ID = 2 #在这里设定开关的编号……
  11.   $center_hud = false #这里决定是否将HUD(状态窗口)居中显示……
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化别名
  14.   #--------------------------------------------------------------------------
  15.   alias raz_hud_main main
  16.   alias raz_hud_update update
  17.   #--------------------------------------------------------------------------
  18.   # ● 主进程
  19.   #--------------------------------------------------------------------------  
  20.   def main
  21.     @size = $game_party.actors.size
  22.     raz_hud_main
  23.     @hud_window.dispose
  24.     for i in 0...$game_party.actors.size
  25.       @hud_dummy[i].dispose
  26.     end #for
  27.   end #def
  28.   #--------------------------------------------------------------------------
  29.   # ● 刷新画面
  30.   #--------------------------------------------------------------------------  
  31.   def update
  32.     if @size != $game_party.actors.size
  33.       @hud_window.refresh
  34.       show_window
  35.     end #if
  36.     if @hud != true
  37.       main_window
  38.     end #if
  39.     turn_hud_on_off
  40.     @hud_window.update
  41.     raz_hud_update
  42.   end #def
  43.   #--------------------------------------------------------------------------
  44.   # ● 与状态窗口的显示行为相关的语句
  45.   #--------------------------------------------------------------------------   
  46.   def show_window
  47.     @size = $game_party.actors.size
  48.     for i in 0..3
  49.       @hud_dummy[i].visible = ($game_party.actors[i] != nil)
  50.     end #for
  51.   end #def
  52.   #--------------------------------------------------------------------------
  53.   # ● 与状态窗口的创建相关的语句
  54.   #--------------------------------------------------------------------------     
  55.   def main_window
  56.     @opacity = 200
  57.     @hud_dummy = []
  58.     for i in 0...4
  59.       y = $game_party.actors.size - 1
  60.       x = 240 - (y * 80)
  61.       if $center_hud == true
  62.         @hud_dummy[i] = Window_Base.new(160 * i + x, 372,160, 108)
  63.       else
  64.         @hud_dummy[i] = Window_Base.new(160 * i, 372,160, 108)
  65.       end #if
  66.       @hud_dummy[i].opacity = @opacity
  67.       @hud_dummy[i].visible = false
  68.     end #for
  69.     @hud_window = Window_HUD.new
  70.     for i in 0...$game_party.actors.size
  71.       @hud_dummy[i].visible = $game_party.actors[i] != nil
  72.     end #for
  73.     @hud = true
  74.   end #def
  75.   #--------------------------------------------------------------------------
  76.   # ● 与状态窗口的开关相关的语句
  77.   #--------------------------------------------------------------------------   
  78.   def turn_hud_on_off
  79.    if $game_switches[SWITCH_ID] == false #关掉开关
  80.     @hud_window.visible = false
  81.       for i in 0...$game_party.actors.size
  82.         @hud_dummy[i].visible = false
  83.       end #for
  84.     end #if
  85.    if $game_switches[SWITCH_ID] == true #打开开关
  86.      @hud_window.visible = true
  87.      for i in 0...$game_party.actors.size
  88.        @hud_dummy[i].visible = true
  89.      end #for
  90.    end #if
  91.   end #def
  92. end #class
  93. #==============================================================================
  94. # ■ Window_HUD
  95. #------------------------------------------------------------------------------
  96. #  地图画面中显示的状态窗口。
  97. #==============================================================================
  98. class Window_HUD < Window_Base
  99.   #--------------------------------------------------------------------------
  100.   # ● 初始化对象
  101.   #--------------------------------------------------------------------------
  102.   def initialize
  103.     super(0, 0, 800, 600)
  104.     self.contents = Bitmap.new(width - 32, height - 32)
  105.     self.opacity = 0
  106.     for i in 0...$game_party.actors.size
  107.       actor = $game_party.actors[i]
  108.       eval("@old_hp#{i+1} = actor.hp; @old_sp#{i+1} = actor.sp; @old_exp#{i+1} = actor.now_exp")
  109.     end #for
  110.     refresh
  111.   end #def
  112.   #--------------------------------------------------------------------------
  113.   # ● 刷新
  114.   #--------------------------------------------------------------------------
  115.   def refresh
  116.     self.contents.clear
  117.     for i in 0...$game_party.actors.size
  118.       a = $game_party.actors.size - 1
  119.       actor = $game_party.actors[i]
  120.       if $center_hud == true
  121.        x = (i * 160 + 25) + (240 - (a * 80))
  122.       else
  123.        x = i * 160 + 25
  124.       end #if
  125.       self.contents.font.size = 21
  126.       draw_actor_graphic(actor, x - 15, 445)
  127.       self.contents.font.color = normal_color
  128.       self.contents.draw_text(x - 25, 360, 100, 32, actor.name)
  129.       width = 100
  130.       height = 6
  131.       draw_slant_bar(x + 8, 396, actor.hp, actor.maxhp, width, height, Color.new(150, 0, 0), Color.new(155, 155, 60))
  132.       draw_slant_bar(x + 8, 416, actor.sp, actor.maxsp, width, height, Color.new(0, 0, 150), Color.new(60, 155, 155))
  133.       unless actor.level == 99
  134.         draw_slant_bar(x + 8, 436, actor.now_exp, actor.next_exp, width, height, Color.new(0, 150, 0), Color.new(60, 255, 60))
  135.       else
  136.         draw_slant_bar(x + 8, 436, 1, 1, width = 100, height = 6, Color.new(0, 150, 0), Color.new(60, 255, 60))
  137.       end #unless
  138.       self.contents.font.size = 16
  139.       draw_actor_state(actor, x + 45, 360)
  140.       self.contents.font.color = normal_color
  141.       self.contents.font.bold = true
  142.       self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  143.       self.contents.draw_text(x + 16, 382, 100, 32, "#{actor.hp}/#{actor.maxhp}", 1)
  144.       self.contents.font.color = actor.sp == 0 ? crisis_color : actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  145.       self.contents.draw_text(x + 16, 402, 100, 32, "#{actor.sp}/#{actor.maxsp}", 1)
  146.       self.contents.font.color = system_color
  147.       self.contents.font.size = 20
  148.       self.contents.font.bold = false
  149.       self.contents.draw_text(x, 384, 50, 32, "力") #HP的显示文本,可修改。
  150.       self.contents.draw_text(x, 404, 50, 32, "气") #SP的显示文本,可修改。
  151.       self.contents.draw_text(x, 424, 50, 32, "验") #EXP的显示文本,可修改。
  152.     end #for
  153.   end #def
  154.   #--------------------------------------------------------------------------
  155.   # ● 刷新画面
  156.   #--------------------------------------------------------------------------
  157.   def update
  158.     super
  159.     for i in 0...$game_party.actors.size
  160.       actor = $game_party.actors[i]
  161.       if (eval("@old_hp#{i+1}") != actor.hp or eval("@old_sp#{i+1}") != actor.sp or
  162.         eval("@old_exp#{i+1}") != actor.now_exp)
  163.         refresh
  164.         eval("@old_hp#{i+1} = actor.hp; @old_sp#{i+1} = actor.sp; @old_exp#{i+1} = actor.now_exp")
  165.       end #if
  166.     end #super
  167.   end #def
  168. end #class
  169. #==============================================================================
  170. # ■ Window_Base
  171. #------------------------------------------------------------------------------
  172. #  游戏中全部窗口的超级类。
  173. #==============================================================================
  174. class Window_Base < Window
  175.   #状态条的绘制
  176.   def draw_slant_bar(x, y, min, max, width = 152, height = 6,
  177.       bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
  178.     for i in 0..height
  179.       self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
  180.     end #for
  181.     for i in 1..(height - 1)
  182.       r = 100 * (height - i) / height + 0 * i / height
  183.       g = 100 * (height - i) / height + 0 * i / height
  184.       b = 100 * (height - i) / height + 0 * i / height
  185.       a = 255 * (height - i) / height + 255 * i / height
  186.       self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
  187.     end #for
  188.     for i in 1..( (min / max.to_f) * width - 1)
  189.       for j in 1..(height - 1)
  190.         r = bar_color.red * (width - i) / width + end_color.red * i / width
  191.         g = bar_color.green * (width - i) / width + end_color.green * i / width
  192.         b = bar_color.blue * (width - i) / width + end_color.blue * i / width
  193.         a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
  194.         self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
  195.       end #for
  196.     end #for
  197.   end #def
  198. end #class
  199. #==============================================================================
  200. # ■ Game_Actor
  201. #------------------------------------------------------------------------------
  202. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  203. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  204. #==============================================================================
  205. class Game_Actor
  206.   #获取当前EXP
  207.   def now_exp
  208.     return @exp - @exp_list[@level]
  209.   end #def
  210.   #获取下一级需要EXP的数值
  211.   def next_exp
  212.     return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  213.   end #def
  214. end




XY窗口的話
試試看改
RUBY 代码复制
  1. class Scene_Map
  2. alias xy_66rpg_main main
  3. def main
  4.    @xy_window = Window_xy.new
  5.    @xy_window.x = 640 - 160
  6.    @xy_window.y = 480 - 96
  7.    @xy_window.opacity = 0



@xy_window.x = 640 - 160

@xy_window.x = 160

效果如圖






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