Project1

标题: 如何在战斗选项前显示不同的图标?像VX那样。 [打印本页]

作者: 爆焰    时间: 2012-2-13 19:51
标题: 如何在战斗选项前显示不同的图标?像VX那样。
就是说,要在战斗的选项前面显示一个小图标。比如:攻击的前面是一把剑,防御是个盾牌之类的图标,像VX那样的效果,请问如何设置?dsu_plus_rewardpost_czw
作者: 2719358    时间: 2012-2-13 20:49
本帖最后由 2719358 于 2012-2-14 07:12 编辑
  1. #==============================================================================
  2. # ■ Window_BattleCommand
  3. #------------------------------------------------------------------------------
  4. #  战斗的命令选择行窗口。
  5. #==============================================================================
  6. moudle HawRan
  7.   moudle BattleCommand
  8.     Icon={"文件名" #攻击
  9.           "文件名" #技能
  10.           "文件名" #防御
  11.           "文件名" #物品
  12.           }
  13.   end

  14. end
  15. class Window_BattleCommand < Window_Command
  16.   #--------------------------------------------------------------------------
  17.   # ● 初始化对像
  18.   #     width    : 窗口的宽
  19.   #     commands : 命令字符串序列
  20.   #--------------------------------------------------------------------------
  21.   def initialize(width, commands)
  22.     # 由命令的个数计算出窗口的高
  23.     super(width,commands)
  24.     @icon=[]
  25.     5.times{|i|
  26.       @icon[i]=sprite.new
  27.       @icon[i].bitmap = bitmp.new(HawRan::BattleCommand::Icon[i]);
  28.     }
  29.    
  30.   end
  31. end
复制代码
未测试= =
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])改成@actor_command_window = Window_BattleCommand.new(160, [s1, s2, s3, s4])
作者: qdqlloxe    时间: 2012-2-13 20:55
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================


放在 Icons里面就行了

module Momo_IconCommand
  # 图标名称设定
  ATTACK_ICON_NAME = "B攻击" # 攻撃
  SKILL_ICON_NAME = "B技能"   # 特技
  GUARD_ICON_NAME = "B道具"  # 道具
  ITEM_ICON_NAME = "B防御"     # 防御
  ESCAPE_ICON_NAME = "B逃跑"  # 逃跑
  # X坐标修正
  X_PLUS = -47
  # Y坐标修正
  Y_PLUS = +35
  # 选择时图标的动作
  # 0:静止 1:放大
  SELECT_TYPE = 1
  # 闪烁时光芒的颜色
  FLASH_COLOR = Color.new(255, 255, 255, 128)
  # 闪烁时间
  FLASH_DURATION = 10
  # 闪烁间隔
  FLASH_INTERVAL = 20
  # 是否写出文字的名称
  COM_NAME_DROW = true
  # 文字名称是否移动
  COM_NAME_MOVE = true
  # 文字内容
  ATTACK_NAME = "攻击"    # 攻击
  SKILL_NAME = "特技"   # 特技
  GUARD_NAME = "道具"     # 道具
  ITEM_NAME = "防御"  # 防御
  ESCAPE_NAME = "逃跑"  # 逃跑
  # 文字颜色
  COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  # 文字坐标修正
  COM_NAME_X_PLUS = 0
  COM_NAME_Y_PLUS = 0
end

class Window_CommandIcon < Window_Selectable
  attr_accessor :last_index
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, commands)
    super(x, y, 32, 32)
    # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
    self.windowskin = RPG::Cache.windowskin("")
    @item_max = commands.size
    @commands = commands
    @column_max = commands.size
    @index = 0
    @last_index = nil
    @name_sprite = nil
    @sprite = []
    refresh
  end
  def dispose
    super
    for sprite in @sprite
      sprite.dispose unless sprite.nil?
    end
    @name_sprite.dispose unless @name_sprite.nil?
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    @name_sprite.dispose unless @name_sprite.nil?
    for sprite in @sprite
      sprite.dispose unless sprite.nil?
    end
    @name_sprite = nil
    draw_com_name if Momo_IconCommand::COM_NAME_DROW
    @sprite = []
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    @sprite[index] = Sprite_Icon.new(nil, @commands[index])
    @sprite[index].z = self.z + 100##########################
  end
  def draw_com_name
    @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
   
  end
  
  # 更新
  def update
    super
    icon_update
    com_name_update if Momo_IconCommand::COM_NAME_DROW
    if move_index?
      @last_index = self.index
    end
  end
  # アイコンの更新
  def icon_update
    for i in [email protected]
      @sprite.active = (self.index == i)
      @sprite.x = self.x + i * 24
      @sprite.y = self.y + 0
      @sprite.z = (self.index == i) ? self.z + 2 : self.z + 1
      @sprite.visible = self.visible
      @sprite.update
    end
  end
  # コマンドネームの更新
  def com_name_update
    if move_index?
      @name_sprite.name = get_com_name
    end
    @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
    @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
    @name_sprite.z = self.z + 1
    @name_sprite.active = self.active
    @name_sprite.visible = self.visible
    @name_sprite.update
  end
  def get_com_name
    make_name_set if @name_set.nil?
    name = @name_set[self.index]
    name = "" if name.nil?
    return name
  end
  def make_name_set
    @name_set = []
    @name_set[0] = Momo_IconCommand::ATTACK_NAME
    @name_set[1] = Momo_IconCommand::SKILL_NAME
    @name_set[2] = Momo_IconCommand::GUARD_NAME
    @name_set[3] = Momo_IconCommand::ITEM_NAME
    @name_set[4] = Momo_IconCommand::ESCAPE_NAME
  end
  def move_index?
    return self.index != @last_index
  end
  def need_reset
    @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
  end
end

# アイコン用スプライト
class Sprite_Icon < Sprite
  attr_accessor :active
  attr_accessor :icon_name
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, icon_name)
    super(viewport)
    @icon_name = icon_name
    @last_icon = @icon_name
    @count = 0
    self.bitmap = RPG::Cache.icon(@icon_name)
    self.ox = self.bitmap.width / 2
    self.oy = self.bitmap.height / 2
    @active = false
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    if @icon_name != @last_icon
      @last_icon = @icon_name
      self.bitmap = RPG::Cache.icon(@icon_name)
    end
    if @active
      @count += 1
      case Momo_IconCommand::SELECT_TYPE
      when 0
        icon_flash
      when 1
        icon_zoom
      end
      @count = 0 if @count == 20
    else
      icon_reset
    end
  end
  def icon_flash
    if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 1
      self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
    end
  end
  def icon_zoom
    case @count
    when 1..10
      zoom = 1.0 + @count / 10.0
    when 11..20
      zoom = 2.0 - (@count - 10) / 10.0
    end
    self.zoom_x = zoom
    self.zoom_y = zoom
  end
  def icon_reset
    @count = 0
    self.zoom_x = 1.0
    self.zoom_y = 1.0
  end
end

# コマンドネーム用スプライト
class Sprite_Comm_Name < Sprite
  attr_accessor :active
  attr_accessor :name
  attr_accessor :need_reset
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, name)
    super(viewport)
    @name = name
    @last_name = nil
    @count = 0
    @x_plus = 0
    @opa_plus = 0
    @need_reset = false
    @active = false
    self.bitmap = Bitmap.new(160, 32)
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    if @active
      if need_reset?
        @need_reset = false
        @last_name = @name
        text_reset
      end
      move_text if Momo_IconCommand::COM_NAME_MOVE
    end
  end
  def move_text
    @count += 1
    @x_plus = [@count * 8, 80].min
    self.x = self.x - 80 + @x_plus
    self.opacity = @count * 25
  end
  def text_reset
    @count = 0
    @x_plus = 0
    self.bitmap.clear
    self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
    self.bitmap.draw_text(0, 0, 160, 32, @name)
  end
  def need_reset?
    return (@name != @last_name or @need_reset)
  end
end

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● プレバトルフェーズ開始
  #--------------------------------------------------------------------------
  alias scene_battle_icon_command_start_phase1 start_phase1
  def start_phase1
    com1 = Momo_IconCommand::ATTACK_ICON_NAME
    com2 = Momo_IconCommand::SKILL_ICON_NAME
    com3 = Momo_IconCommand::GUARD_ICON_NAME
    com4 = Momo_IconCommand::ITEM_ICON_NAME
    com5 = Momo_IconCommand::ESCAPE_ICON_NAME
    @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4,com5])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @actor_command_window.update
    scene_battle_icon_command_start_phase1
  end
  #--------------------------------------------------------------------------
  # ● アクターコマンドウィンドウのセットアップ
  #--------------------------------------------------------------------------
  alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  def phase3_setup_command_window
    scene_battle_icon_command_phase3_setup_command_window
    # アクターコマンドウィンドウの位置を設定
    @actor_command_window.x = command_window_actor_x(@actor_index)
    @actor_command_window.y = command_window_actor_y(@actor_index)
    @actor_command_window.need_reset
  end
  def command_window_actor_x(index)
    $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  end
  def command_window_actor_y(index)
    $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================



‘‘

那要的是什么效果?


──qdqlloxe于2012-2-13 21:12补充以上内容’’

B道具.png (3.24 KB, 下载次数: 8)

B道具.png

B防御.png (3.04 KB, 下载次数: 5)

B防御.png

B攻击.png (3.48 KB, 下载次数: 9)

B攻击.png

B技能.png (3.19 KB, 下载次数: 8)

B技能.png

B逃跑.png (3.23 KB, 下载次数: 10)

B逃跑.png

作者: 2719358    时间: 2012-2-13 21:21
手误= =
你改成module试试= =
此外第一个到第三个"文件名"后面都少加了个, 逗号 自己补上吧//最后一个后面不用加
作者: 爆焰    时间: 2012-2-14 12:11
2719358 发表于 2012-2-13 21:21
手误= =
你改成module试试= =
此外第一个到第三个"文件名"后面都少加了个, 逗号 自己补上吧//最后一个后面 ...

27行出错了,大哥,你测试完再发上来吧,我弄一次就要问一次,你我都很累人的
作者: 2719358    时间: 2012-2-14 12:27
本帖最后由 2719358 于 2012-2-14 15:08 编辑
爆焰 发表于 2012-2-14 12:11
27行出错了,大哥,你测试完再发上来吧,我弄一次就要问一次,你我都很累人的 ...


我手头没有RM= =
  1. #==============================================================================
  2. # ■ Window_BattleCommand
  3. #------------------------------------------------------------------------------
  4. #  战斗的命令选择行窗口。
  5. #==============================================================================
  6. module HawRan
  7.   module BattleCommand
  8.     Icon={"文件名" #攻击
  9.           "文件名" #技能
  10.           "文件名" #防御
  11.           "文件名" #物品
  12.           }
  13.   end

  14. end
  15. class Window_BattleCommand < Window_Command
  16.   #--------------------------------------------------------------------------
  17.   # ● 初始化对像
  18.   #     width    : 窗口的宽
  19.   #     commands : 命令字符串序列
  20.   #--------------------------------------------------------------------------
  21.   def initialize(width, commands)
  22.     # 由命令的个数计算出窗口的高
  23.     super(width,commands)
  24.     @icon=[]
  25.     5.times{|i|
  26.       @icon[i]=Sprite.new
  27.       @icon[i].bitmap = Bitmap.new(HawRan::BattleCommand::Icon[i]);
  28.     }
  29.    
  30.   end
  31. end
复制代码
‘‘
  1. #==============================================================================
  2. # ■ Window_BattleCommand
  3. #------------------------------------------------------------------------------
  4. #  战斗的命令选择行窗口。
  5. #==============================================================================
  6. moudle HawRan
  7.   moudle BattleCommand
  8.     Icon={"文件名", #攻击
  9.           "文件名" ,#技能
  10.           "文件名", #防御
  11.           "文件名" #物品
  12.           }
  13.   end

  14. end
  15. class Window_BattleCommand < Window_Command
  16.   #--------------------------------------------------------------------------
  17.   # ● 初始化对像
  18.   #     width    : 窗口的宽
  19.   #     commands : 命令字符串序列
  20.   #--------------------------------------------------------------------------
  21.   def initialize(width, commands)
  22.     # 由命令的个数计算出窗口的高
  23.     super(width,commands)
  24.     @icon= Array.new(5)
  25.     5.times{|i|
  26.       @icon[i]=Sprite.new
  27.       @icon[i].bitmap = Bitmap.new(HawRan::BattleCommand::Icon[i])
  28.     }  
  29.   end
  30. end
复制代码
──2719358于2012-2-14 15:07补充以上内容’’


‘‘
  1. #==============================================================================
  2. # ■ Window_BattleCommand
  3. #------------------------------------------------------------------------------
  4. #  战斗的命令选择行窗口。
  5. #==============================================================================
  6. module HawRan
  7.   module BattleCommand
  8.     Icon=["Graphics/icons/001-Weapon01.png", #攻击
  9.           "Graphics/icons/001-Weapon01.png",#技能
  10.           "Graphics/icons/001-Weapon01.png", #防御
  11.           "Graphics/icons/001-Weapon01.png" #物品
  12.           ]
  13.   end

  14. end
  15. class Window_BattleCommand < Window_Command
  16.   #--------------------------------------------------------------------------
  17.   # ● 初始化对像
  18.   #     width    : 窗口的宽
  19.   #     commands : 命令字符串序列
  20.   #--------------------------------------------------------------------------
  21.   def initialize(width, commands)
  22.    
  23.     @icon = Array(4)
  24.     for i in 0...4
  25.       @icon[i] = Bitmap.new(HawRan::BattleCommand::Icon[i])
  26.     end
  27.     super(width,commands)
  28.   end
  29.   def refresh()
  30.     super()
  31.    
  32.     for i in [email protected]
  33.       self.contents.blt(0,32*i,@icon[i],Rect.new(0, 0, 24, 24))
  34.     end
  35.   end
  36.   
  37. end
复制代码


──2719358于2012-2-14 16:40补充以上内容’’
作者: 爆焰    时间: 2012-2-14 21:28
2719358 发表于 2012-2-14 12:27
我手头没有RM= =‘‘──2719358于2012-2-14 15:07补充以上内容’’

当我加入
  1. # 不能逃跑的情况下
  2.     if $game_temp.battle_can_escape == false
  3.       @actor_command_window.disable_item(4)
  4.     end
复制代码
这段脚本后,不能逃跑的情况下,逃跑前面的图片只能显示一丁点是怎么回事?
作者: 2719358    时间: 2012-2-15 07:12
爆焰 发表于 2012-2-14 21:28
当我加入这段脚本后,不能逃跑的情况下,逃跑前面的图片只能显示一丁点是怎么回事? ...

本来就没加上显示逃跑的图片= =
自己在icon中加上
把24,25行的4改成5




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