幻耶 发表于 2011-8-22 15:03:20

环形图标战斗菜单脚本怎么用啊?

一进入战斗就跳出这个出错提示:脚本 ‘环形图标战斗菜单’ 的316行发生了TypeError。cannot convert Array into String


脚本:

########################################################################
#▼▲▼ XRXS_MP 6. 环形菜单 ▼▲▼ # By 和希成纳 、桜雅在土 网上搜索到的不知道对不对
# 翻译者未知
#▼▲▼图标战斗菜单▼▲▼ 没有翻译没有原作者署名 也是来自日本的 因为注释也是日文 不可能国人写的加上日文注释的吧
#########################################################################
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# ▽(以下为XRXS_MP 6. 环形菜单作者的感想)
# 1.在脚本编辑器的Main的前一个位置进行插入操作,然后将本脚本复制到新的页里
# 2.Window_RingMenu最开始的7个RPG::Cache.icon("") 的 "" 的中的图标作用在右边
# 的说明里标注了分别是什么项目的,可以根据需要进行修改
# (最下方禁止使用项目的图标建议使用类似“φ”的图标)
# (译者按:就是原图标上多一个横杠或是斜杠的图片)
###############################################################################
module Momo_IconCommand
# 定义各种图标,以便之后使用
ICON_ITEM = "aniu/B攻击" # 「攻击」项目的图标
ICON_SKILL = "aniu/B技能" # 「特技」项目的图标
ICON_EQUIP = "aniu/B防御" # 「防御」项目的图标
ICON_STATUS = "aniu/B道具" # 「道具」项目的图标
ICON_SAVE = "aniu/B逃跑" # 「逃跑」项目的图标
#ICON_DISABLE= "" # 禁止使用项目的图标
# 选择时图标的动作
# 0:静止 1:放大
SELECT_TYPE = 0
# 闪烁时光芒的颜色
FLASH_COLOR = Color.new(255, 255, 255, 128)
# 闪烁时间
FLASH_DURATION = 10
# 闪烁间隔
FLASH_INTERVAL = 20
end
#==============================================================================
# ■ Window_RingMenu
#------------------------------------------------------------------------------
#  显示环形菜单画面
#==============================================================================
class Window_RingMenu < Window_Base
#--------------------------------------------------------------------------
# ○ 类常量定义
# 这里定义的变量是整个Window_RingMenu类都可以用的常量
# 所有变量名都是用大写,以区别其他变量
#--------------------------------------------------------------------------
# 打开菜单使用的帧数,数字越小打开菜单时速度越快
STARTUP_FRAMES = 12
# 切换选项时使用的帧数,数字越小切换选项速度越快
MOVING_FRAMES = 10
# 环的半径(单位:象素),数字越大环越大←本句为废话
RING_R = 50
# 定义各种状态时的赋值。
# 译注:对于程序而言,个人感觉多此一举…不过的确方便了阅读
MODE_START = 1 # 动画开始时
MODE_WAIT = 2 # 待机中
MODE_MOVER = 3 # 顺时针旋转(往右)
MODE_MOVEL = 4 # 逆时针旋转(往左)
MODE_MOVEZ = 5 # 还原第一个图标
# X坐标修正
X_PLUS = 60
# Y坐标修正
Y_PLUS = 0#100
# 是否写出文字的名称
COM_NAME_DROW = true
# 文字内容
ATTACK_NAME = "攻击" # 攻击
SKILL_NAME = "异能" # 特技
GUARD_NAME = "防御" # 防御
ITEM_NAME = "背包" # 物品
ESCAPE_NAME = "逃跑" # 逃跑
# 文字颜色
COM_NAME_COLOR = Color.new(255, 255, 255, 255)
#--------------------------------------------------------------------------
# ○ 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :index
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize( center_x, center_y , move_flag,cms)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width-32, height-32)
self.opacity = 0
self.back_opacity = 0
s1 = ATTACK_NAME
s2 = SKILL_NAME
s3 = GUARD_NAME
s4 = ITEM_NAME
s5 = ESCAPE_NAME
@commands = [ s1, s2, s3, s4, s5]
@item_max = 5
@index = 0
@items = cms#[ ICON_ITEM, ICON_SKILL, ICON_EQUIP, ICON_STATUS, ICON_SAVE]
@disabled = [ false, false, false, false, false, false ]
@cx = center_x
@cy = center_y
@sprite = []
for i in 0...@item_max
@sprite = Sprite_Icon.new(nil,@items)
end
@xxiu = X_PLUS
@yxiu = Y_PLUS
# 初始化动画
setup_move_start(move_flag)
@old_mode = 0
# 刷新
refresh
end
#追加释放功能
def dispose
for sprite in @sprite
sprite.dispose unless sprite.nil?
end
super
end

#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if @old_mode != @mode
refresh
end
icon_update
end

def icon_update
for i in 0...@sprite.size
# if animation? #判断是否动画中
# @sprite.active = false
# else
# @sprite.active = true
# end
@sprite.active = (self.index == i)
@sprite.z = (self.index == i) ? self.z + 2 : self.z + 1
@sprite.visible = self.visible
@sprite.update
end
end

#--------------------------------------------------------------------------
# ● 画面描绘(刷新)
#--------------------------------------------------------------------------
def refresh
self.contents.clear

# 选择描绘方式
case @mode
when MODE_START
refresh_start
when MODE_WAIT
refresh_wait
@old_mode = @mode
refresh_wait
when MODE_MOVER
refresh_move(1)
when MODE_MOVEL
refresh_move(0)
end
# 指令名描绘
rect = Rect.new(@cx - 325 +X_PLUS, @cy-153+Y_PLUS, self.contents.width-32, 32)
self.contents.font.color = COM_NAME_COLOR
self.contents.draw_text(rect, @commands[@index],1) if COM_NAME_DROW
end
#--------------------------------------------------------------------------
# ○ 画面生成
#--------------------------------------------------------------------------
def refresh_start
d1 = 2.0 * Math::PI / @item_max
d2 = 1.0 * Math::PI / STARTUP_FRAMES
r = RING_R - 1.0 * RING_R * @steps / STARTUP_FRAMES
for i in 0...@item_max
j = i - @index
d = d1 * j + d2 * @steps
x = @cx + ( r * Math.sin( d ) ).to_i
y = @cy - ( r * Math.cos( d ) ).to_i
# draw_item(x, y, i)
@sprite.x = x+@xxiu
@sprite.y = y+@yxiu
end
@steps -= 1
if @steps < 0
@mode = MODE_WAIT
end
end

#--------------------------------------------------------------------------
# ○ 画面再描绘(待机时)
#--------------------------------------------------------------------------
def refresh_wait
d = 2.0 * Math::PI / @item_max
for i in 0...@item_max
j = i - @index
x = @cx + ( RING_R * Math.sin( d * j ) ).to_i
y = @cy - ( RING_R * Math.cos( d * j ) ).to_i
# draw_item(x, y, i)
@sprite.x = x+@xxiu
@sprite.y = y+@yxiu
end
end

#--------------------------------------------------------------------------
# ○ 画面再描绘(旋转时)
# mode : 旋转方向(0 : 逆时针旋转时,1 : 顺时针旋转时)
#--------------------------------------------------------------------------
def refresh_move( mode )
d1 = 2.0 * Math::PI / @item_max
d2 = d1 / MOVING_FRAMES
d2 *= -1 if mode != 0
for i in 0...@item_max
# 以下便是那华丽的曲线公式
j = i - @index
d = d1 * j + d2 * @steps
x = @cx + ( RING_R * Math.sin( d ) ).to_i
y = @cy - ( RING_R * Math.cos( d ) ).to_i
# draw_item(x, y, i)
@sprite.x = x+@xxiu
@sprite.y = y+@yxiu
end
@steps -= 1
if @steps < 0
@mode = MODE_WAIT
end
end

#--------------------------------------------------------------------------
# ● 描绘图片
# i : 项目编号
#--------------------------------------------------------------------------
def draw_item(x, y, i)
rect = Rect.new(0, 0, @items.width, @items.height)
if @index == i
self.contents.blt( x, y, @items, rect )
if @disabled[@index]
self.contents.blt( x, y, ICON_DISABLE, rect )
end
else
self.contents.blt( x, y, @items, rect, 220 )
if @disabled[@index]
self.contents.blt( x, y, ICON_DISABLE, rect, 220 )
end
end
end

#--------------------------------------------------------------------------
# ● 项目无效化
# index : 项目编号
#--------------------------------------------------------------------------
def disable_item(index)
for i in 0...@sprite.size
@sprite.dispose if @sprite != nil
end
@disabled = true
end

#--------------------------------------------------------------------------
# ○ 初始化动画准备
#--------------------------------------------------------------------------
def setup_move_start(move_flag,kg = false)
@mode = move_flag ? MODE_START : 1
@steps = move_flag ? STARTUP_FRAMES : 1
end

#--------------------------------------------------------------------------
# ○ 回转动画准备
#--------------------------------------------------------------------------
def setup_move_move(mode)
if mode == MODE_MOVER
@index -= 1
@index = @items.size - 1 if @index < 0
elsif mode == MODE_MOVEL
@index += 1
@index = 0 if @index >= @items.size
else
return
end
@mode = mode
@steps = MOVING_FRAMES
end
#--------------------------------------------------------------------------
# ○ 还原动画准备
#--------------------------------------------------------------------------
def setup_move_huan(mode)
if mode == MODE_MOVEL
@index = 0
@mode = mode
@steps = MOVING_FRAMES
end
end
#--------------------------------------------------------------------------
# ○ 判断是否在动画中
#--------------------------------------------------------------------------
def animation?
return @mode != MODE_WAIT
end
end
##############################################

# アイコン用スプライト
class Sprite_Icon < Sprite
attr_accessor :active
attr_accessor :icon_name
#------------------------------------------------------------------------
# ● オブジェクト初期化
#------------------------------------------------------------------------
def initialize(viewport, icon_name)
super(viewport)
@icon_name = 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 @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 Scene_Battle
#------------------------------------------------------------------------
# ● プレバトルフェーズ開始
#------------------------------------------------------------------------
alias :orzfoxzu_update_phase3_basic_command :update_phase3_basic_command
def update_phase3_basic_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 转向前一个角色的指令输入
phase3_prior_actor
@actor_command_window.refresh
return
end

###############
# 动画中不能执行光标处理
# 这句的意思就是如果正处于动画中就return,这样下面的语句就不会执行了
# 换言之,如果正处于动画处理中,那么就无法移动菜单
return if @actor_command_window.animation?
###############

# 按下 ↑ 或 ← 键的情况下 #改成相反的
# if Input.press?(Input::UP) or Input.press?(Input::LEFT)
if Input.press?(Input::DOWN) or Input.press?(Input::RIGHT)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 向左旋转
@actor_command_window.setup_move_move(Window_RingMenu::MODE_MOVEL)
return
end

# 按下 ↓ 或 → 键的情况下 #改成相反的
# if Input.press?(Input::DOWN) or Input.press?(Input::RIGHT)
if Input.press?(Input::UP) or Input.press?(Input::LEFT)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 向右旋转
@actor_command_window.setup_move_move(Window_RingMenu::MODE_MOVER)
return
end

##################
orzfoxzu_update_phase3_basic_command
end

alias scene_battle_icon_command_start_phase1 start_phase1
def start_phase1
#指定图标的图片
com1 = Momo_IconCommand::ICON_ITEM
com2 = Momo_IconCommand::ICON_SKILL
com3 = Momo_IconCommand::ICON_EQUIP
com4 = Momo_IconCommand::ICON_STATUS
com5 = Momo_IconCommand::ICON_SAVE
#赋予圆心的位置和初试开关
@flag = true
px = 220
py = 240
@actor_command_window = Window_RingMenu.new(px,py,@flag,)
@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.setup_move_start(0,true)
@actor_command_window.refresh
# @actor_command_window.x = @actor_index * 160
@actor_command_window.x = 20#280#@active_battler.screen_x - 10#320#
@actor_command_window.y = 120#0#@active_battler.screen_y - 140#120#
@actor_command_window.z = 50#@active_battler.screen_z - 1
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
end
end
页: [1]
查看完整版本: 环形图标战斗菜单脚本怎么用啊?