Project1
标题:
关于变量槽得绘制?
[打印本页]
作者:
纳尔德
时间:
2012-8-4 08:54
标题:
关于变量槽得绘制?
我想制作一个赋予变量1得变量槽,例如我在脚本先绘制一个矩形,接着,随着变量1得数值改变变量条得宽度。和血槽得绘制方法差不多,但是不懂的怎么计算变量槽得算法。求教大大,事件脚本都可以哦!记得是赋予变量得。 dsu_plus_rewardpost_czw
作者:
极地小鸥
时间:
2012-8-4 09:03
本帖最后由 Kimu 于 2012-8-4 10:01 编辑
参照使用方法
# -----------------------------------------------------------------------------
# 值槽脚本随机生成系统(SLOTCR) By.Clov
# 通用版本:RMXP(RGSS1) RMVX(RGSS2) RMVX ACE(RGSS3)
# 使用方法:在全部窗口类插入即可 例:draw_cr(0,0,变量1,变量2,'开心值',100,10)
# 参数说明:x x坐标,y y坐标,current 当前值,max 最大值,txt 显示的文字
# width 值槽的宽,height 值槽的高
# 背景与边框没有随机的必要,请自行到脚本里设置
# -----------------------------------------------------------------------------
class Window_Base
def draw_cr(x,y,current,max,txt='',width=128,height=15)
#颜色1、颜色2
c1=[59, 191, 119];c2=[253, 94, 1]
#边框色颜色
bk_color = Color.new(255,255,255,255)
#数值是否显示
num = true
#显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
num_align = 1
#计算比率
bl = current.to_f / max
#计算实际宽
w = (width*bl).round
#描绘值槽
r = c1[0];g = c1[1];b = c1[2]
plus_r = (c2[0]-c1[0])/((width-1)*bl)
plus_g = (c2[1]-c1[1])/((width-1)*bl)
plus_b = (c2[2]-c1[2])/((width-1)*bl)
w.times {|k|
contents.fill_rect(x+k, y, 1, height, Color.new(r,g,b,255))
r+=plus_r;g+=plus_g;b+=plus_b}
contents.fill_rect(x-1, y-1, width+2, 1, bk_color)
contents.fill_rect(x-1, y+height, width+2, 1, bk_color)
contents.fill_rect(x-1, y, 1, height, bk_color)
contents.fill_rect(x+width, y, 1, height, bk_color)
#描绘文字
txt_w = contents.text_size(txt).width + 2
contents.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
contents.draw_text(x,y+height/2-12, width, 24,
current.to_s+'/'+max.to_s,num_align) if num
end
end
复制代码
作者:
945127391
时间:
2012-8-5 00:45
算法么……
大概是:
变量1/上限*槽宽度
复制代码
吧
作者:
沙漠点灰
时间:
2012-8-5 12:50
本帖最后由 hcm 于 2012-8-10 09:16 编辑
x = 0
y = 0
hgt = 10 # 高度
max = 100 # 100%时,变量1的值
wid = 100 # 100%时的宽度
tmp = $game_variables[1] # 带入变量1
rect = Rect.new(x,y,(tmp/max.to_f*wid).to_i,hgt) # 生成矩形
复制代码
rect就是你想要的矩形
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1