Project1
标题:
RTAB中图标战斗菜单选择命令的问题~
[打印本页]
作者:
君迁子
时间:
2009-5-17 21:13
标题:
RTAB中图标战斗菜单选择命令的问题~
如题,我已经在“图标战斗菜单”中设定了上下左右键的移动命令,结果测试出来的效果却和设定的完全不同,左右键完全无用。虽然我知道在RTAB中,左右键还有选择角色的作用,但是如果把RTAB战斗脚本里的这一部分注释掉的话也没有什么改观,到底是什么问题呢?
http://rpg.blue/upload_program/d ... _017b_122994584.rar
[LINE]1,#dddddd[/LINE]
版务信息:本贴由楼主自主结贴~
作者:
veal
时间:
2009-5-17 21:49
跟RTAB左右键选择角色没有关系 =v= 由于Window_CommandIcon继承Window_Selectable的关系,一旦调用父类update函数就会用Window_Selectable的方法改变index,你在super之后获取的index已经不正确了,解决方法是将@last_index = self.index移到super前面
但是!这样还不能完全解决问题,因为有move_index?这么个方法存在,在按左右键的时候会导致move_index?返回false。move_index?这个方法好像没有存在意义,让它永远返回true就可以了
下面是修改好后的图标战斗菜单脚本
#==========================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==========================================================================
module Momo_IconCommand
# 图标名称设定
ATTACK_ICON_NAME = "bmenu_A" # 攻撃
SKILL_ICON_NAME = "bmenu_S" # 特技
GUARD_ICON_NAME = "bmenu_G" # 防御
ITEM_ICON_NAME = "bmenu_I" # 物品
WEAPON_ICON_NAME = "bmenu_W"
ESCAPE_ICON_NAME = "bmenu_R" #逃跑
# X坐标修正
X_PLUS = -40
# Y坐标修正
Y_PLUS = -180
# 选择时图标的动作
# 0:静止 1:放大
SELECT_TYPE = 0
# 闪烁时光芒的颜色
FLASH_COLOR = Color.new(255, 249, 131, 140)
# 闪烁时间
FLASH_DURATION = 10
# 闪烁间隔
FLASH_INTERVAL = 20
# 是否写出文字的名称
COM_NAME_DROW = true
# 文字名称是否移动
COM_NAME_MOVE = true
# 文字内容
ATTACK_NAME = "攻击" # 攻击
SKILL_NAME = "招术" # 特技
GUARD_NAME = "调息" # 防御
ITEM_NAME = "道具" # 物品
WEAPON_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 = 1
@index_max = 0
@last_index = nil
@name_sprite = nil
@sprite = []
@sprite_menu = Sprite.new
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
@last_index = self.index
super
icon_update
com_name_update if Momo_IconCommand::COM_NAME_DROW
if move_index?
# 判断当前光标位置
###########################################################################
case @last_index
#攻击 法术 防御
#物品 换武器 逃跑
when 0 # 攻击
if Input.repeat?(Input::RIGHT)
# 光标指向法术
@index = 1
end
if Input.repeat?(Input::LEFT)
# 光标指向防御
@index = 2
end
if Input.repeat?(Input::DOWN)
# 光标指向物品
@index = 3
end
if Input.repeat?(Input::UP)
# 光标指向物品
@index = 3
end
when 1 # 法术
if Input.repeat?(Input::RIGHT)
# 光标指向防御
@index = 2
end
if Input.repeat?(Input::LEFT)
# 光标指向攻击
@index = 0
end
if Input.repeat?(Input::DOWN)
# 光标指向换武器
@index = 4
end
if Input.repeat?(Input::UP)
# 光标指向换武器
@index = 4
end
when 2 # 防御
if Input.repeat?(Input::RIGHT)
# 光标指向攻击
@index = 0
end
if Input.repeat?(Input::LEFT)
# 光标指向法术
@index = 1
end
if Input.repeat?(Input::DOWN)
# 光标指向逃跑
@index = 5
end
if Input.repeat?(Input::UP)
# 光标指向逃跑
@index = 5
end
when 3 # 物品
if Input.repeat?(Input::RIGHT)
# 光标指向武器更换
@index = 4
end
if Input.repeat?(Input::LEFT)
# 光标指向逃跑
@index = 5
end
if Input.repeat?(Input::DOWN)
# 光标指向攻击
@index = 0
end
if Input.repeat?(Input::UP)
# 光标指向攻击
@index = 0
end
when 4 # 武器更换
if Input.repeat?(Input::RIGHT)
# 光标指向逃跑
@index = 5
end
if Input.repeat?(Input::LEFT)
# 光标指向物品
@index = 3
end
if Input.repeat?(Input::DOWN)
# 光标指向法术
@index = 1
end
if Input.repeat?(Input::UP)
# 光标指向法术
@index = 1
end
when 5 # 逃跑
if Input.repeat?(Input::RIGHT)
# 光标指向物品
@index = 3
end
if Input.repeat?(Input::LEFT)
# 光标指向武器更换
@index = 4
end
if Input.repeat?(Input::DOWN)
# 光标指向防御
@index = 2
end
if Input.repeat?(Input::UP)
# 光标指向防御
@index = 2
end
end
#######################################################################
end
end
# アイコンの更新
def icon_update
for i in
[email protected]
@sprite[i].active = (self.index == i)
#@sprite[0].x = self.x - i * 16 + 50
#@sprite[0].y = self.y + 0 -20
#@sprite[1].x = self.x - i * 16 + 50
#@sprite[1].y = self.y + 39-20
#@sprite[2].x = self.x - i * 16 + 50
#@sprite[2].y = self.y + 39*2 -20
#@sprite[3].x = self.x - i * 16 + 50
#@sprite[3].y = self.y + 39*3 -20
#@sprite[4].x = self.x - i * 16 + 50
#@sprite[4].y = self.y + 39*4 -20
#@sprite[5].x = self.x - i * 16 + 50
#@sprite[5].y = self.y + 39*5 -20
@sprite[0].x = 5 + 275
@sprite[0].y = 4 + 124
@sprite[1].x = 45 + 275
@sprite[1].y = 4 + 124
@sprite[2].x = 85 + 275
@sprite[2].y = 4 + 124
@sprite[3].x = 5 + 275
@sprite[3].y = 104 + 124
@sprite[4].x = 45 + 275
@sprite[4].y = 104 + 124
@sprite[5].x = 85 + 275
@sprite[5].y = 104 + 124
@sprite[i].z = 9000
#@sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1
@sprite[i].visible = self.visible
@sprite[i].update
end
end
# コマンドネームの更新
def com_name_update
# if move_index?
@name_sprite.name = get_com_name
# end
@name_sprite.x = 80#self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS#
@name_sprite.y = 350#self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS#
@name_sprite.z = 9000#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::WEAPON_NAME
@name_set[5] = Momo_IconCommand::ESCAPE_NAME
end
def move_index?
return true#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 == 2
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(60, 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, 0, 0, @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::WEAPON_ICON_NAME
com6 = Momo_IconCommand::ESCAPE_ICON_NAME
@actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4, com5,com6])
@actor_command_window.y = 120
@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,使用和转载请保留此信息
#==========================================================================
复制代码
另外我测试的时候,更换武器这个选项导致系统卡死,不过这个应该不是这一帖的解决范围之内的事情吧=v= [LINE]1,#dddddd[/LINE]
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者:
君迁子
时间:
2009-5-17 22:06
嗯,更换武器的脚本没拷进来,难怪卡死了=v=bb
多谢vealTvT
作者:
veal
时间:
2009-5-17 22:08
其实我很担心换武器那里是我这么一改弄成的=v=
作者:
天使喝可乐
时间:
2009-5-17 22:10
为什么我用这个脚本 左右还是不能用= = 囧
作者:
veal
时间:
2009-5-17 22:16
以下引用
天使喝可乐于2009-5-17 14:10:41
的发言:
为什么我用这个脚本 左右还是不能用= = 囧
这个我就不清楚了,你确定是把脚本粘帖进君迁子提供的工程里面?既然君迁子认可了,脚本应该是没有问题的
作者:
君迁子
时间:
2009-5-17 22:18
因为我之后把RTAB的LR切换人物那里注释了,也就是只能QW切换了~
默认是左右键和QW都能切换人物的,因为图标战斗上下左右都用到了,半即时的时候键位功能就冲突了嘛
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1