Project1

标题: 怎么让图标式战斗菜单变得可以用上下键选择 [打印本页]

作者: 飞舞の布偶熊    时间: 2012-1-26 14:10
标题: 怎么让图标式战斗菜单变得可以用上下键选择
本帖最后由 飞舞の布偶熊 于 2012-1-26 14:14 编辑

我用了灵儿续传的战斗菜单(仿新仙剑),可是当我移动光标时,却按得很吃力,只能用左右键交替,并且选到第四个指令时还得按←键返回到第三个,第二个,第一个。。。请问怎么让战斗菜单可以使用上下左右键交换?我只是 半脚本盲……
dsu_plus_rewardpost_czw
作者: 腐琴琴    时间: 2012-1-26 14:58
请问……能看看脚本和范例工程么……主站上搜不到……
作者: dbshy    时间: 2012-1-26 17:06
本帖最后由 dbshy 于 2012-1-26 17:08 编辑

lz找一下Input::RIGHT Input::LEFT 改成 Input::DOWN  Input::UP
试下 不一定行
最好贴脚本
作者: 双叶GL    时间: 2012-1-27 01:17
- -不是在按键脚本中设置选择吗

打开脚本按搜索,"方向键被按下的情况"
假如没有就搜索"Input.repeat?(Input:: RIGHT)"
作者: 飞舞の布偶熊    时间: 2012-2-4 11:19
#==============================================================================
#==============================================================================

module Momo_IconCommand
  # 图标名称设定
  ATTACK_ICON_NAME = "Attack" # 攻撃
  SKILL_ICON_NAME = "Skill"   # 特技
  GUARD_ICON_NAME = "Guard"  # 防御
  ITEM_ICON_NAME = "Thing"     # 物品
  # X坐标修正
  X_PLUS = -320
  # Y坐标修正
  Y_PLUS = -100
  # 选择时图标的动作
  # 0:静止 1:放大
  SELECT_TYPE = 0
  # 闪烁时光芒的颜色
  FLASH_COLOR = Color.new(255, 255, 255, 128)
  # 闪烁时间
  FLASH_DURATION = 10
  # 闪烁间隔
  FLASH_INTERVAL = 20
  # 是否写出文字的名称
  COM_NAME_DROW = false
  # 文字名称是否移动
  COM_NAME_MOVE = false
  # 文字内容
  ATTACK_NAME = "攻击"    # 攻击
  SKILL_NAME = "特技"   # 特技
  GUARD_NAME = "防御"     # 防御
  ITEM_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, 37, 37)
    # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
    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 + 1
  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
    qx = 25
    qy = 385
    for i in [email protected]
      @sprite.active = (self.index == i)
      @sprite[0].x = 40 +qx
      @sprite[0].y = -15 +qy
      @sprite[1].x = 0 + qx
      @sprite[1].y = 23 + qy
      @sprite[2].x = 40 + qx
      @sprite[2].y = 59 + qy
      @sprite[3].x = 81 + qx
      @sprite[3].y = 23 + qy
      #@sprite.x = self.x + i * 56
      #@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
  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.y = 0
    self.x = self.x - 300 - @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
    @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    $fff = 0
    @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 = 1000
    @actor_command_window.y = 1000
    @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

#==============================================================================
#==============================================================================

作者: f26401004    时间: 2012-2-4 21:30
請將 @column_max 改成 1

作者: dbshy    时间: 2012-2-4 22:17
刚看了LZ贴出的脚本,应该没问题
LZ你全局搜索一下Input:: RIGHT 把出现的脚本贴出来看看
作者: zjd540921697    时间: 2012-2-5 14:31
把这个脚本插在main前
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. class Window_Selectable
  5.   #--------------------------------------------------------------------------
  6.   # ● 刷新画面
  7.   #--------------------------------------------------------------------------
  8.   def update
  9.     super
  10.     # 可以移动光标的情况下
  11.     if self.active and @item_max > 0 and @index >= 0
  12.       # 方向键下被按下的情况下
  13.       if Input.repeat?(Input::DOWN)
  14.         # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  15.         # 或光标位置在(项目数-列数)之前的情况下
  16.         if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
  17.            @index < @item_max - @column_max
  18.           # 光标向下移动
  19.           $game_system.se_play($data_system.cursor_se)
  20.           @index = (@index + @column_max) % @item_max
  21.         else
  22.           if @column_max >= 2 and  @index == @item_max - 1
  23.           $game_system.se_play($data_system.cursor_se)
  24.           @index = -1
  25.           end
  26.           # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  27.           if @column_max >= 2 and @index < @item_max - 1
  28.            # 光标向右移动
  29.            $game_system.se_play($data_system.cursor_se)
  30.            @index += 1
  31.           end
  32.         end
  33.       end
  34.       # 方向键上被按下的情况下
  35.       if Input.repeat?(Input::UP)
  36.         # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  37.         # 或光标位置在列之后的情况下
  38.         if (@column_max == 1 and Input.trigger?(Input::UP)) or
  39.            @index >= @column_max
  40.           # 光标向上移动
  41.           $game_system.se_play($data_system.cursor_se)
  42.           @index = (@index - @column_max + @item_max) % @item_max
  43.         else
  44.           if  @column_max >= 2 and @index == 0
  45.           $game_system.se_play($data_system.cursor_se)
  46.           @index = @item_max
  47.           end      
  48.           # 列数为 2 以上并且、光标位置在 0 之后的情况下
  49.           if @column_max >= 2 and @index > 0
  50.           # 光标向左移动
  51.           $game_system.se_play($data_system.cursor_se)
  52.           @index -= 1
  53.           end
  54.         end
  55.       end
  56.       # 方向键右被按下的情况下
  57.       if Input.repeat?(Input::RIGHT)      
  58.         if @column_max >= 2 and @index == @item_max - 1
  59.           $game_system.se_play($data_system.cursor_se)
  60.           @index = -1
  61.         end
  62.          # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  63.         if @column_max >= 2 and @index < @item_max - 1
  64.            # 光标向右移动
  65.            $game_system.se_play($data_system.cursor_se)
  66.            @index += 1
  67.         else
  68.           # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  69.           # 或光标位置在(项目数-列数)之前的情况下
  70.           if (@column_max == 1 and Input.trigger?(Input::RIGHT)) or
  71.            @index < @item_max - @column_max
  72.           # 光标向下移动
  73.           $game_system.se_play($data_system.cursor_se)
  74.           @index = (@index + @column_max) % @item_max
  75.           end
  76.         end  
  77.       end     
  78.       # 方向键左被按下的情况下
  79.       if Input.repeat?(Input::LEFT)
  80.         if  @column_max >= 2 and @index == 0
  81.           $game_system.se_play($data_system.cursor_se)
  82.           @index = @item_max
  83.         end      
  84.        # 列数为 2 以上并且、光标位置在 0 之后的情况下
  85.         if @column_max >= 2 and @index > 0
  86.          # 光标向左移动
  87.           $game_system.se_play($data_system.cursor_se)
  88.           @index -= 1
  89.         else
  90.           # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  91.           # 或光标位置在列之后的情况下
  92.           if (@column_max == 1 and Input.trigger?(Input::LEFT)) or
  93.            @index >= @column_max
  94.           # 光标向上移动
  95.           $game_system.se_play($data_system.cursor_se)
  96.           @index = (@index - @column_max + @item_max) % @item_max
  97.           end
  98.         end
  99.       end
  100.       # R 键被按下的情况下
  101.       if Input.repeat?(Input::R)
  102.         # 显示的最后行在数据中最后行上方的情况下
  103.         if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
  104.           # 光标向后移动一页
  105.           $game_system.se_play($data_system.cursor_se)
  106.           @index = [@index + self.page_item_max, @item_max - 1].min
  107.           self.top_row += self.page_row_max
  108.         end
  109.       end
  110.       # L 键被按下的情况下
  111.       if Input.repeat?(Input::L)
  112.         # 显示的开头行在位置 0 之后的情况下
  113.         if self.top_row > 0
  114.           # 光标向前移动一页
  115.           $game_system.se_play($data_system.cursor_se)
  116.           @index = [@index - self.page_item_max, 0].max
  117.           self.top_row -= self.page_row_max
  118.         end
  119.       end
  120.     end
  121.     # 刷新帮助文本 (update_help 定义了继承目标)
  122.     if self.active and @help_window != nil
  123.       update_help
  124.     end
  125.     # 刷新光标矩形
  126.     update_cursor_rect
  127.   end
  128. end

  129. #==============================================================================
  130. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  131. #==============================================================================
复制代码





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