Project1
标题:
何如让这脚本可以显示多个变量
[打印本页]
作者:
fannaoshaoxiang
时间:
2010-8-15 08:15
标题:
何如让这脚本可以显示多个变量
这个脚本是伪双计时器 可是我嫌计时变量太少 我想要更多 高手帮帮忙
=begin
====设定=======================================================================
请先设定好以下两个变量的编号,默认为1
当编号为『$显示计时器开关编号』的开关为ON是,第二个计时器将会显示。
当编号为『$伪计时器变量编号』的变量大过0是,第二个计时器将开始操作。
为第二个计时器设定时间时,请直接设定秒数。
====解说=======================================================================
这个功能是有点无聊,置于为什么是伪双计时器呢,因为我根本没有添加多一个计时器,
只是借用Sprite_Timer刷新的功能来减去变量罢了,其实没什么特别。
全脚本只修改了Sprite_Timer,冲突性应该很少了。
===============================================================================
=end
###############################################################################
$显示计时器开关编号 = 1
$伪计时器变量编号 = 1
###############################################################################
#==============================================================================
# ■ Sprite_Timer
#------------------------------------------------------------------------------
# 显示计时器用的活动块。监视 $game_system 、活动块状态
# 自动变化。
#==============================================================================
class Sprite_Timer < Sprite
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super
self.bitmap = Bitmap.new(88, 96)
self.bitmap.font.name = "Arial"
self.bitmap.font.size = 32
self.x = 640 - self.bitmap.width
self.y = 0
self.z = 500
@_timer_counter = 40
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 判断计时器是否为执行时可见
if $game_system.timer_working or $game_switches[$显示计时器开关编号]
self.visible = true
else
self.visible = false
end
# 用变量做第二个计时器
if $game_variables[$伪计时器变量编号] > 0
@_timer_counter -= 1 if @_timer_counter > 0
if @_timer_counter == 0
$game_variables[$伪计时器变量编号] -= 1
@_timer_counter = 40
end
end
# 还原计算操作
if $game_variables[$伪计时器变量编号] == 0 and @_timer_counter != 40
@_timer_counter == 40
end
# 如果有必要再次描绘计时器
if $game_system.timer / Graphics.frame_rate != @total_sec or
$game_variables[$伪计时器变量编号] != @_timer
########################################################################
self.bitmap.clear
########################################################################
# 设置计时器执行中为可见
if $game_system.timer_working
# 计算总计秒数
@total_sec = $game_system.timer / Graphics.frame_rate
# 生成计时器显示用字符串
min = @total_sec / 60
sec = @total_sec % 60
text = sprintf("%02d:%02d", min, sec)
# 描绘计时器
self.bitmap.font.color.set(255, 255, 255)
self.bitmap.draw_text(0,0,88,48, text, 1)
end
########################################################################
# 设置计时器执行中为可见
if $game_switches[$显示计时器开关编号]
# 直接是秒数
@_timer = $game_variables[$伪计时器变量编号]
# 生成计时器显示用字符串
min = @_timer / 60
sec = @_timer % 60
text = sprintf("%02d:%02d", min, sec)
# 描绘计时器
self.bitmap.font.color.set(255, 255, 255)
self.bitmap.draw_text(0,48,88,48,text,1)
end
########################################################################
end
end
end
复制代码
作者:
越前リョーマ
时间:
2010-8-15 11:02
参考我在这贴的回复,自己制作计时器吧。
http://rpg.blue/thread-151927-1-2.html
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1