查看: 2352|回复: 1

[已经解决] 关于战斗光标和行走图战斗的问题

[复制链接]
梦石
0
星屑
75
在线时间
231 小时
注册时间
2014-10-5
回帖
226
发表于 2014-11-23 12:07:10 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
RT,就是我用的是SideView  Ver100   横版战斗,然后使用了敌人行走图动态效果,
在使用了战斗光标脚本后,战斗光标的位置,在最上面,我不知道修改哪里,
才能让光标的箭头和名字框往下一些

javascript:;

下面是战斗光标脚本还有我游戏里面的截图

[pre lang="ruby" line="1" file="1"]#==============================================================================
# ■ Window_BtArrowHelp
#==============================================================================
class Window_BtArrowHelp < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, Graphics.width, fitting_height(1))
    self.openness = 0
  end
  #--------------------------------------------------------------------------
  # ● バトラー設定
  #--------------------------------------------------------------------------
  def set_battler(battler, height)
    if battler != @battler
      @battler = battler
      w = contents.text_size(@battler.name).width
      self.width = w + standard_padding * 2
      create_contents
      refresh
      update_position(height)
      self.openness = 0
      open
    end
  end
  #--------------------------------------------------------------------------
  # ● 表示位置
  #--------------------------------------------------------------------------
  def update_position(height)
    if @battler.actor?#角色帮助窗口坐标
      xx = [0, @battler.sv.x / 100 - self.width / 2 - 44].max #~~
      yy = [0, @battler.sv.y / 100  - height - 60].max #~~
    else#敌人帮助窗口坐标
      xx = [0, @battler.screen_x - self.width / 2 -20].max #~~
      yy = [0, @battler.screen_y - height - 60].max #~~
    end
    self.x = [xx, Graphics.width  - self.width ].min
    self.y = [yy, Graphics.height - self.height].min
  end
  #--------------------------------------------------------------------------
  # ● クリア
  #--------------------------------------------------------------------------
  def clear
    contents.clear
    @battler = nil
    self
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ(バトラーステータス)
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text(0, 0, contents.width, line_height, @battler.name, 1)
#~     draw_battler_states
  end
  #--------------------------------------------------------------------------
  # ● ステート描画
  #--------------------------------------------------------------------------
  def draw_battler_states
    w = contents.text_size(@battler.name).width + 4
    draw_actor_icons(@battler, w, 0)
  end
end[/pre]



[pre lang="ruby" line="1" file="2"]#==============================================================================
# ■ BtArrow_Base
#==============================================================================
class BtArrow_Base < Sprite
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :active
  attr_reader   :index
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport=nil)
    @count = 0
    @index = -1
    @handler = {}
    @cursor_fix = false
    @cursor_all = false
    super(viewport)
    self.bitmap = Cache.system(arrow_file)
    self.ox = arrow_width / 2
    self.src_rect = Rect.new(0, 0, arrow_width, bitmap.height)
    deactivate.hide
  end
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    return 0
  end
  #--------------------------------------------------------------------------
  # ● アロー画像分割数
  #--------------------------------------------------------------------------
  def arrow_col
    return 4
  end
  #--------------------------------------------------------------------------
  # ● アロー画像幅
  #--------------------------------------------------------------------------
  def arrow_width
    bitmap.width / arrow_col
  end
  #--------------------------------------------------------------------------
  # ● アロー画像
  #--------------------------------------------------------------------------
  def arrow_file
    return "Arrow"
  end
  #--------------------------------------------------------------------------
  # ● アローの表示
  #--------------------------------------------------------------------------
  def show
    self.visible = true
    self
  end
  #--------------------------------------------------------------------------
  # ● アローの非表示
  #--------------------------------------------------------------------------
  def hide
    self.visible = false
    self
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウのアクティブ化
  #--------------------------------------------------------------------------
  def activate
    self.active = true
    self
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウの非アクティブ化
  #--------------------------------------------------------------------------
  def deactivate
    self.active = false
    self
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    return unless self.visible
    super
    update_cursor
    process_cursor_move
    process_handling
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 : アロー更新
  #--------------------------------------------------------------------------
  def update_cursor
    @count = (@count + 1) % arrow_round
    if (@count % arrow_mtn) == 0
      x = (@count / arrow_mtn) * arrow_width
      self.src_rect = Rect.new(x, 0, arrow_width, bitmap.height)
    end
  end
  #--------------------------------------------------------------------------
  # ● アローアニメーションの更新間隔
  #--------------------------------------------------------------------------
  def arrow_mtn
    return 4
  end
  #--------------------------------------------------------------------------
  # ● アローアニメーション
  #--------------------------------------------------------------------------
  def arrow_round
    arrow_col * arrow_mtn
  end
  #--------------------------------------------------------------------------
  # ● アクティブ状態の変更
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    update_cursor
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● カーソル位置の設定
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_cursor
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● 項目の選択
  #--------------------------------------------------------------------------
  def select(index)
    self.index = index if index
  end
  #--------------------------------------------------------------------------
  # ● 項目の選択解除
  #--------------------------------------------------------------------------
  def unselect
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの設定
  #--------------------------------------------------------------------------
  def help_window=(help_window)
    @help_window = help_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウ更新メソッドの呼び出し
  #--------------------------------------------------------------------------
  def call_update_help
    update_help if active && @help_window
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # ● 選択項目の有効状態を取得
  #--------------------------------------------------------------------------
  def current_item_enabled?
    return true
  end
  #--------------------------------------------------------------------------
  # ● 動作に対応するハンドラの設定
  #     method : ハンドラとして設定するメソッド (Method オブジェクト)
  #--------------------------------------------------------------------------
  def set_handler(symbol, method)
    @handler[symbol] = method
  end
  #--------------------------------------------------------------------------
  # ● ハンドラの存在確認
  #--------------------------------------------------------------------------
  def handle?(symbol)
    @handler.include?(symbol)
  end
  #--------------------------------------------------------------------------
  # ● ハンドラの呼び出し
  #--------------------------------------------------------------------------
  def call_handler(symbol)
    @handler[symbol].call if handle?(symbol)
  end
  #--------------------------------------------------------------------------
  # ● カーソルを下に移動
  #--------------------------------------------------------------------------
  def cursor_down(wrap = false)
    if index < item_max - col_max || (wrap && col_max == 1)
      select((index + col_max) % item_max)
    end
  end
  #--------------------------------------------------------------------------
  # ● カーソルを上に移動
  #--------------------------------------------------------------------------
  def cursor_up(wrap = false)
    if index >= col_max || (wrap && col_max == 1)
      select((index - col_max + item_max) % item_max)
    end
  end
  #--------------------------------------------------------------------------
  # ● カーソルを右に移動
  #--------------------------------------------------------------------------
  def cursor_right(wrap = false)
    if col_max >= 2 && (index < item_max - 1 || wrap)
      select((index + 1) % item_max)
    end
  end
  #--------------------------------------------------------------------------
  # ● カーソルを左に移動
  #--------------------------------------------------------------------------
  def cursor_left(wrap = false)
    if col_max >= 2 && (index > 0 || wrap)
      select((index - 1 + item_max) % item_max)
    end
  end
  #--------------------------------------------------------------------------
  # ● カーソルの移動処理
  #--------------------------------------------------------------------------
  def process_cursor_move
    last_index = @index
    cursor_right (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
    cursor_left   (Input.trigger?(:UP))    if Input.repeat?(:UP)
    cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
    cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
    Sound.play_cursor if @index != last_index
  end
  #--------------------------------------------------------------------------
  # ● 決定やキャンセルなどのハンドリング処理
  #--------------------------------------------------------------------------
  def process_handling
    return unless active
    return process_ok       if ok_enabled?        && Input.trigger?(:C)
    return process_cancel   if cancel_enabled?    && Input.trigger?(:B)
    return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
    return process_pageup   if handle?(:pageup)   && Input.trigger?(:L)
  end
  #--------------------------------------------------------------------------
  # ● 決定処理の有効状態を取得
  #--------------------------------------------------------------------------
  def ok_enabled?
    handle?(:ok)
  end
  #--------------------------------------------------------------------------
  # ● キャンセル処理の有効状態を取得
  #--------------------------------------------------------------------------
  def cancel_enabled?
    handle?(:cancel)
  end
  #--------------------------------------------------------------------------
  # ● 決定ボタンが押されたときの処理
  #--------------------------------------------------------------------------
  def process_ok
    if current_item_enabled?
      Sound.play_ok
      Input.update
      deactivate
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
  #--------------------------------------------------------------------------
  # ● 決定ハンドラの呼び出し
  #--------------------------------------------------------------------------
  def call_ok_handler
    call_handler(:ok)
  end
  #--------------------------------------------------------------------------
  # ● キャンセルボタンが押されたときの処理
  #--------------------------------------------------------------------------
  def process_cancel
    Sound.play_cancel
    Input.update
    deactivate
    call_cancel_handler
  end
  #--------------------------------------------------------------------------
  # ● キャンセルハンドラの呼び出し
  #--------------------------------------------------------------------------
  def call_cancel_handler
    call_handler(:cancel)
  end
end


#==============================================================================
# ■ BtArrow_Actor
#==============================================================================
class BtArrow_Actor < BtArrow_Base
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    item_max
  end
  #--------------------------------------------------------------------------
  # ● 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    $game_party.battle_members.size
  end
  #--------------------------------------------------------------------------
  # ● アクターオブジェクト取得
  #--------------------------------------------------------------------------
  def actor
    $game_party.battle_members[@index]
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 : アロー更新
  #--------------------------------------------------------------------------
  def update_cursor
    super
      self.x = actor.sv.x / 100 - 44 #~~
      self.y = actor.sv.y / 100 - actor.sv.ch #~~
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_battler(actor,actor.sv.ch)
  end
end

#==============================================================================
# ■ BtArrow_Enemy
#==============================================================================
class BtArrow_Enemy < BtArrow_Base
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    item_max
  end
  #--------------------------------------------------------------------------
  # ● 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    $game_troop.alive_members.size
  end
  #--------------------------------------------------------------------------
  # ● エネミーオブジェクト取得
  #--------------------------------------------------------------------------
  def enemy
    $game_troop.alive_members[@index]
  end
  #--------------------------------------------------------------------------
  # ● バトラーの高さ
  #--------------------------------------------------------------------------
  def battler
    Cache.battler(enemy.battler_name, enemy.battler_hue)
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 : アロー更新
  #--------------------------------------------------------------------------
  def update_cursor
    super
    self.x = enemy.screen_x - 20 #~~
    self.y = enemy.screen_y - battler.height #~~
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_battler(enemy, battler.height)
  end
end
[/pre]



[pre lang="ruby" line="1" file="3"]#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 更新全部窗口
  #--------------------------------------------------------------------------
  def update_all_windows
    super
    @actor_window.update
    @enemy_window.update
  end
  #--------------------------------------------------------------------------
  # ● 生成帮助窗口
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_Help.new
    @help_window.visible = false
    @arrow_help_window = Window_BtArrowHelp.new
  end
  #--------------------------------------------------------------------------
  # ● 生成角色窗口
  #--------------------------------------------------------------------------
  def create_actor_window
    @actor_window = BtArrow_Actor.new
    @actor_window.set_handler(:ok,     method(:on_actor_ok))
    @actor_window.set_handler(:cancel, method(:on_actor_cancel))
  end  
  #--------------------------------------------------------------------------
  # ● 生成敌人窗口
  #--------------------------------------------------------------------------
  def create_enemy_window
    @enemy_window = BtArrow_Enemy.new
    @enemy_window.set_handler(:ok,     method(:on_enemy_ok))
    @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  end
  #--------------------------------------------------------------------------
  # ● 角色选择开始
  #--------------------------------------------------------------------------
  def select_actor_selection
    @actor_window.index = 0
    @actor_window.help_window = @arrow_help_window
    @actor_window.show.activate   
  end
  #--------------------------------------------------------------------------
  # ● 角色“确定”
  #--------------------------------------------------------------------------
  alias on_actor_ok_origi on_actor_ok
  def on_actor_ok   
    @arrow_help_window.clear.close
    on_actor_ok_origi
  end
  #--------------------------------------------------------------------------
  # ● 角色“取消”
  #--------------------------------------------------------------------------
  def on_actor_cancel
    @actor_window.hide
    @arrow_help_window.clear.close
    case @actor_command_window.current_symbol
    when :skill
      @skill_window.show.activate
    when :item
      @item_window.show.activate
    end
  end
  #--------------------------------------------------------------------------
  # ● 开始选择敌人
  #--------------------------------------------------------------------------
  def select_enemy_selection
    @enemy_window.index = 0
    @enemy_window.help_window = @arrow_help_window
    @enemy_window.show.activate
  end
  #--------------------------------------------------------------------------
  # ●  敌人“确定”
  #--------------------------------------------------------------------------
  alias on_enemy_ok_origi on_enemy_ok
  def on_enemy_ok
    @arrow_help_window.clear.close
    on_enemy_ok_origi
  end
  #--------------------------------------------------------------------------
  # ● 敌人“取消”
  #--------------------------------------------------------------------------
  def on_enemy_cancel
    @enemy_window.hide
    @arrow_help_window.clear.close
    case @actor_command_window.current_symbol
    when :attack
      @actor_command_window.open.activate
    when :skill
      @skill_window.show.activate
    when :item
      @item_window.show.activate
    end
  end
  #--------------------------------------------------------------------------
  # ● 技能“确定”
  #--------------------------------------------------------------------------
  alias on_skill_ok_origi on_skill_ok
  def on_skill_ok
    @skill_window.hide
    on_skill_ok_origi
  end

  #--------------------------------------------------------------------------
  # ● 物品“确定”
  #--------------------------------------------------------------------------
  alias on_item_ok_origi on_item_ok
  def on_item_ok
    @item_window.hide
    on_item_ok_origi
  end
end[/pre]
QQ截图20141123120058.png
梦石
0
星屑
55
在线时间
185 小时
注册时间
2014-9-4
回帖
80
发表于 2014-11-23 17:47:42 | 显示全部楼层
修改的地方很好找呀,第一个脚本34行
  1. else#敌人帮助窗口坐标
  2.   xx = [0, @battler.screen_x - self.width / 2 -20].max #~~
  3.   yy = [0, @battler.screen_y - height - 60].max #~~
  4. end
复制代码
改yy = [0, @battler.screen_y - height + 10].max

具体自己微调,-10 +10 +20 调到你觉得不错的位置

点评

太谢谢了  发表于 2014-11-24 23:48

评分

参与人数 1梦石 +1 收起 理由
taroxd + 1 认可答案

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部