- 注册时间
- 2004-10-18
- 最后登录
- 2010-4-14
⑤进阶
- 积分
- 542
|
我研究了一晚上…
结果发现人家使用了一个华丽至渣的曲线公式……
结合目前我的数学水平,根本就只能得到“茫然”这个结果
而这个曲线公式正是这个如流水般的形态优美的环形菜单的精华中的精华
结果彼母浪费了一晚上时间…
我还是看不懂…
而且我还是带感冒看的啊〒﹏〒
可耻,打印出来明天在课上研究…
顺便放出我边看边注释后的版本…
# ▼▲▼ XRXS_MP 6. 环形菜单 ▼▲▼
# by 和希
###############################################################################
# 环形菜单脚本(中文注释版)
# writen by 和希
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# ▽导入
# 1.在脚本编辑器的Main的前一个位置进行插入操作,然后将本脚本复制到新的页里
# 2.Window_RingMenu最开始的7个RPG::Cache.icon("") 的 "" 的中的图标作用在右边
# 的说明里标注了分别是什么项目的,可以根据需要进行修改
# (最下方禁止使用项目的图标建议使用类似“φ”的图标)
# (译者按:就是原图标上多一个横杠或是斜杠的图片)
# 3.类常量定义最下方的 SE_STARTUP = "" 的 "" 的中是打开菜单时的音效的名字
#
# ▽スクリプト触れる人へ(以下为作者的感想)
# とりあえず動く物を目標に作ったものなので(志低いw)、座標の調整などが不完全です。
# より正確にアクターの画面座標を取得する処理を追加したり、アクター一覧の位置を
# 変えたり、文字表示などなどを調整するといい感じに仕上がる気がします。
#
###############################################################################
#==============================================================================
# ■ Window_RingMenu
#------------------------------------------------------------------------------
# 显示环形菜单画面
#==============================================================================
class Window_RingMenu < Window_Base
#--------------------------------------------------------------------------
# ○ 类常量定义
# 这里定义的变量是整个Window_RingMenu类都可以用的常量
# 所有变量名都是用大写,以区别其他变量
#--------------------------------------------------------------------------
# 打开菜单使用的帧数,数字越小打开菜单时速度越快
STARTUP_FRAMES = 20
# 切换选项时使用的帧数,数字越小切换选项速度越快
MOVING_FRAMES = 5
# 环的半径(单位:象素),数字越大环越大←本句为废话
RING_R = 64
# 定义各种图标,以便之后使用
ICON_ITEM = RPG::Cache.icon("034-Item03") # 「道具」项目的图标
ICON_SKILL = RPG::Cache.icon("044-Skill01") # 「特技」项目的图标
ICON_EQUIP = RPG::Cache.icon("001-Weapon01") # 「装备」项目的图标
ICON_STATUS = RPG::Cache.icon("050-Skill07") # 「状态」项目的图标
ICON_SAVE = RPG::Cache.icon("038-Item07") # 「存储」项目的图标
ICON_EXIT = RPG::Cache.icon("046-Skill03") # 「结束」项目的图标
ICON_DISABLE= RPG::Cache.icon("") # 禁止使用项目的图标
# 打开菜单时的音效
SE_STARTUP = "056-Right02"
# 定义各种状态时的赋值。
# 译注:对于程序而言,个人感觉多此一举…不过的确方便了阅读
MODE_START = 1 # 动画开始时
MODE_WAIT = 2 # 待机中
MODE_MOVER = 3 # 顺时针旋转(往右)
MODE_MOVEL = 4 # 逆时针旋转(往左)
#--------------------------------------------------------------------------
# ○ 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :index # ?
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize( center_x, center_y )
super(0, 0, 640, 480)
self.contents = Bitmap.new(width-32, height-32)
self.opacity = 0
self.back_opacity = 0
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "状态"
s5 = "储存"
s6 = "结束"
@commands = [ s1, s2, s3, s4, s5, s6 ]
@item_max = 6
@index = 0
@items = [ ICON_ITEM, ICON_SKILL, ICON_EQUIP, ICON_STATUS, ICON_SAVE, ICON_EXIT ]
@disabled = [ false, false, false, false, false, false ]
@cx = center_x - 16
@cy = center_y - 16
# 初始化动画
setup_move_start
# 刷新
refresh
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
refresh
end
#--------------------------------------------------------------------------
# ● 画面描绘(刷新)
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# 选择描绘方式
case @mode
when MODE_START
refresh_start
when MODE_WAIT
refresh_wait
when MODE_MOVER
refresh_move(1)
when MODE_MOVEL
refresh_move(0)
end
# 指令名描绘
rect = Rect.new(@cx - 272, @cy + 24, self.contents.width-32, 32)
self.contents.draw_text(rect, @commands[@index],1)
end
#--------------------------------------------------------------------------
# ○ 画面生成
#--------------------------------------------------------------------------
def refresh_start
d1 = 2.0 * Math: I / @item_max
d2 = 1.0 * Math: I / 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)
end
@steps -= 1
if @steps < 1
@mode = MODE_WAIT
end
end
#--------------------------------------------------------------------------
# ○ 画面再描绘(待机时)
#--------------------------------------------------------------------------
def refresh_wait
d = 2.0 * Math: I / @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)
end
end
#--------------------------------------------------------------------------
# ○ 画面再描绘(旋转时)
# mode : 旋转方向(0 : 逆时针旋转时,1 : 顺时针旋转时)
#--------------------------------------------------------------------------
def refresh_move( mode )
d1 = 2.0 * Math: I / @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)
end
@steps -= 1
if @steps < 1
@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, 128 )
if @disabled[@index]
self.contents.blt( x, y, ICON_DISABLE, rect, 128 )
end
end
end
#--------------------------------------------------------------------------
# ● 项目无效化
# index : 项目编号
#--------------------------------------------------------------------------
def disable_item(index)
@disabled[index] = true
end
#--------------------------------------------------------------------------
# ○ 初始化动画准备
#--------------------------------------------------------------------------
def setup_move_start
@mode = MODE_START
@steps = STARTUP_FRAMES
if SE_STARTUP != nil and SE_STARTUP != ""
Audio.se_play("Audio/SE/" + SE_STARTUP, 80, 100)
end
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 animation?
return @mode != MODE_WAIT
end
end
#==============================================================================
# ■ Window_RingMenuStatus
#------------------------------------------------------------------------------
# 显示环形菜单画面下同伴状态的窗口。
# 本窗口定义与Window_MenuStatus雷同
#==============================================================================
class Window_RingMenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(204, 64, 232, 352)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 80
y = 80 * i
actor = $game_party.actors
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y + 24)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
end
end
end |
|