赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 5 |
经验 | 7006 |
最后登录 | 2019-7-6 |
在线时间 | 132 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 468
- 在线时间
- 132 小时
- 注册时间
- 2016-6-15
- 帖子
- 151
|
追加一个脚本,战斗指针
- #==============================================================================
- # ■ Sprite_BattleArrow
- #==============================================================================
- class Sprite_BattleArrow < Sprite
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :index
- attr_accessor :select_all
- attr_accessor :can_select_all
- attr_accessor :members
- attr_accessor :add_x
- attr_accessor :on_ok_method
- attr_accessor :on_cancel_method
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize(type, viewport, can_select_all = false)
- super(viewport)
- self.bitmap = Cache.system("BattleArrow")
- @type = type
- case @type
- when :enemy
- self.ox = 0
- src_rect.set(32, 0-35, 32, 32+50)
- @members = $game_troop.members
- @add_x = 30-10
- when :actor
- self.ox = 32
- src_rect.set(0, 0-35, 32, 32+50)
- @members = $game_party.battle_members
- @add_x = -30
- else
- self.ox = 16
- src_rect.set(0, 0, 32, 32)
- @members = []
- @add_x = 0
- end
- self.oy = 32
- self.z = 2500
- self.visible = false
- @index = 0
- @old_index = @index
- @select_all = false
- @can_select_all = can_select_all
- update
- end
- #--------------------------------------------------------------------------
- # ● 设置
- #--------------------------------------------------------------------------
- def setup(can_select_all)
- @can_select_all = can_select_all
- @select_all = false
- @index = @old_index
- case @type
- when :actor
- @members = $game_party.battle_members
- when :enemy
- @members = $game_troop.members
- else
- @members = []
- end
- self.visible = true
- update
- end
- #--------------------------------------------------------------------------
- # ● 获取光标指向的战斗者
- #--------------------------------------------------------------------------
- def battler
- return members[index]
- end
- #--------------------------------------------------------------------------
- # ● 设置光标位置
- #--------------------------------------------------------------------------
- def index=(index)
- @index = index
- update
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- return unless visible
- if Input.trigger?(13)
- Sound.play_ok
- on_ok_method.call if on_ok_method
- return
- end
- if Input.trigger?(12)
- Sound.play_cancel
- on_cancel_method.call if on_cancel_method
- return
- end
- if Input.trigger?(4) or Input.trigger?(6)
- if @select_all
- @select_all = false
- @index = @old_index
- else
- if @can_select_all
- @select_all = true
- @old_index = @index
- end
- end
- end
- case @type
- when :actor
- update_actor
- when :enemy
- update_enemy
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新选择角色
- #--------------------------------------------------------------------------
- def update_actor
- if @select_all
- @index += 1
- @index %= members.size
- else
- old_index = @index
- for i in 0..members.size
- @index = i
- if @index == members.size
- @index = old_index
- break
- end
- next unless battler
- self_x = battler.fscreen_x + add_x
- self_y = battler.fscreen_y
- end
- if Input.repeat?(2)
- Sound.play_cursor
- @index += 1
- @index %= members.size
- end
- if Input.repeat?(8)
- Sound.play_cursor
- @index += members.size - 1
- @index %= members.size
- end
- end
- if battler
- self.x = battler.fscreen_x + add_x
- self.y = battler.fscreen_y
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新选择敌人
- #--------------------------------------------------------------------------
- def update_enemy
- if @select_all
- members.size.times do
- @index += 1
- @index %= members.size
- break if not battler.hidden?
- end
- else
- members.size.times do
- break if not battler.hidden?
- @index += 1
- @index %= members.size
- end
- old_index = @index
- for i in 0..members.size
- @index = i
- if @index == members.size
- @index = old_index
- break
- end
- next if battler.hidden?
- self_x = battler.screen_x + add_x
- self_y = battler.screen_y
- end
- if Input.repeat?(2)
- Sound.play_cursor
- members.size.times do
- @index += 1
- @index %= members.size
- break if not battler.hidden?
- end
- end
- if Input.repeat?(8)
- Sound.play_cursor
- members.size.times do
- @index += members.size - 1
- @index %= members.size
- break if not battler.hidden?
- end
- end
- end
- if battler != nil
- self.x = battler.screen_x + add_x
- self.y = battler.screen_y
- end
- end
- end
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- alias hzhj_terminate_battle_arrow terminate
- def terminate
- @actor_arrow.dispose
- @enemy_arrow.dispose
- hzhj_terminate_battle_arrow
- end
- #--------------------------------------------------------------------------
- # ● 刷新所有窗口
- #--------------------------------------------------------------------------
- alias hzhj_update_all_windows_battle_arrow update_all_windows
- def update_all_windows
- hzhj_update_all_windows_battle_arrow
- @actor_arrow.update
- @enemy_arrow.update
- end
- #--------------------------------------------------------------------------
- # ● 生成角色窗口
- #--------------------------------------------------------------------------
- def create_actor_window
- viewport = @viewport #@spriteset.viewport1
- @actor_arrow = Sprite_BattleArrow.new(:actor, viewport, false)
- @actor_arrow.on_ok_method = method(:on_actor_ok)
- @actor_arrow.on_cancel_method = method(:on_actor_cancel)
- end
- #--------------------------------------------------------------------------
- # ● 生成敌人窗口
- #--------------------------------------------------------------------------
- def create_enemy_window
- viewport = @viewport #@spriteset.viewport1
- @enemy_arrow = Sprite_BattleArrow.new(:enemy, viewport, false)
- @enemy_arrow.on_ok_method = method(:on_enemy_ok)
- @enemy_arrow.on_cancel_method = method(:on_enemy_cancel)
- end
- #--------------------------------------------------------------------------
- # ● 开始选择队友
- #--------------------------------------------------------------------------
- def select_actor_selection(can_select_all = false)
- @actor_arrow.setup(can_select_all)
- @skill_window.hide
- @item_window.hide
- end
- #--------------------------------------------------------------------------
- # ● 角色“确定”
- #--------------------------------------------------------------------------
- def on_actor_ok
- target_index = @actor_arrow.select_all ? 65535 : @actor_arrow.index
- BattleManager.actor.input.target_index = target_index
- @skill_window.hide
- @item_window.hide
- @actor_arrow.visible = false
- next_command
- end
- #--------------------------------------------------------------------------
- # ● 角色“取消”
- #--------------------------------------------------------------------------
- def on_actor_cancel
- case @actor_command_window.current_symbol
- when :skill
- @skill_window.show.activate
- when :item
- @item_window.show.activate
- end
- @actor_arrow.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 开始选择敌人
- #--------------------------------------------------------------------------
- def select_enemy_selection(can_select_all = false)
- @enemy_arrow.setup(can_select_all)
- # @actor_command_window.hide
- @skill_window.hide
- @item_window.hide
- end
- #--------------------------------------------------------------------------
- # ● 敌人“确定”
- #--------------------------------------------------------------------------
- def on_enemy_ok
- target_index = @enemy_arrow.select_all ? 65535 : @enemy_arrow.index
- BattleManager.actor.input.target_index = target_index
- @skill_window.hide
- @item_window.hide
- @enemy_arrow.visible = false
- next_command
- end
- #--------------------------------------------------------------------------
- # ● 敌人“取消”
- #--------------------------------------------------------------------------
- def on_enemy_cancel
- case @actor_command_window.current_symbol
- when :attack
- @actor_command_window.show.activate
- when :skill
- @skill_window.show.activate
- when :status
- @actor_command_window.show.activate
- when :item
- @item_window.show.activate
- end
- @enemy_arrow.visible = false
- end
- end
复制代码
在graphics/system下放置这个图片文件
|
|