Project1
标题:
文字描边脚本的问题(如何临时变色)
[打印本页]
作者:
p7l8k90
时间:
2010-10-2 10:39
标题:
文字描边脚本的问题(如何临时变色)
本帖最后由 p7l8k90 于 2010-10-3 10:26 编辑
我用了文字描边脚本,由于某种原因需要临时改变文字和描边/阴影的颜色,文字的颜色改掉了,但是描边和阴影却无从下手,希望各位大侠指点,以下是文字描边脚本,我没改什么东西只是改了一下阴影和描边的默认颜色,啊对了,最好改完颜色之后能还原成默认颜色,拜谢了!
#==============================================================================
# ◎ GPRA_Bitmap
#------------------------------------------------------------------------------
# ◎ Bitmap功能加强
#------------------------------------------------------------------------------
# 制作者:绿梨子红苹果
# 个人主页:vbgm.9126.com
# E-Mail:
[email protected]
# QQ:42378361
#==============================================================================
class Bitmap
# 影子字
def draw_text_s(x, y, width, height, str, align=0)
# 保存当前颜色
r=self.font.color.red
g=self.font.color.green
b=self.font.color.blue
# 颜色更改成黑色
self.font.color.set(255, 255, 255)
# 绘制影子
self.draw_text(x+2, y+2, width, height, str, align)
# 恢复原始字色
self.font.color.set(r,g,b)
# 绘制原来的字
self.draw_text(x, y, width, height, str, align)
end
# 描边字
def draw_text_f(x, y, width, height, str, align=0)
# 保存当前颜色
r=self.font.color.red
g=self.font.color.green
b=self.font.color.blue
# 颜色更改成黑色
self.font.color.set(255, 0, 0)
# 绘制边框
self.draw_text(x-1, y-1, width, height, str, align)
self.draw_text(x-1, y+1, width, height, str, align)
self.draw_text(x+1, y-1, width, height, str, align)
self.draw_text(x+1, y+1, width, height, str, align)
self.draw_text(x, y-1, width, height, str, align)
self.draw_text(x, y+1, width, height, str, align)
self.draw_text(x-1, y, width, height, str, align)
self.draw_text(x+1, y, width, height, str, align)
# 恢复原始字色
self.font.color.set(r,g,b)
# 绘制原来的字
self.draw_text(x, y, width, height, str, align)
end
end
复制代码
作者:
凯蒂洛斯
时间:
2010-10-2 19:41
:sleepy:虽然有些看不懂……但是阴影字和描边字的原理是把该字体颜色的亮度给改成最暗以达到黑色的效果,然后阴影字是各向下向右移动两像素,描边字是上下左右各移动一像素……如果改的话应该是在这里改:
第20行 self.font.color.set(255, 255, 255)修改成255以下的数字(我真不知道是修改哪个……)
第35行 self.font.color.set(255, 0, 0)也修改成255以下的数字(如果是按这个的话应该是改第一个吧……)
注意这样改只能修改亮度,想要改变色调的话应该是动后面两个,但是……我真的不知道该动哪个……
想要读懂RGSS只需要用英汉互译就OK……LZ需要的话可以尝试一下。
另追加一个东西:
http://www.rpgchina.net/read-htm-tid-38563.html
完毕……
作者:
p7l8k90
时间:
2010-10-3 07:48
本帖最后由 p7l8k90 于 2010-10-3 09:48 编辑
我看字体阴影就是重复绘制字体,然后z值设置在普通字以下,那个255255255是我后改的,原先的阴影是黑色,我因为需要改成了白色,描边就是重复绘制两遍字体,完了z值也都在普通字以下,两遍字体一个大,一个小,那个颜色我也改了成红色了,我现在就是想在战斗结算(Window_BattleResult)的时候吧阴影临时改成黑色,然后再改回来,不知道怎么弄……以下是稍微改动的战斗结算
#==============================================================================
# ■ Window_BattleResult
#------------------------------------------------------------------------------
# 战斗结束时、显示获得的 EXP 及金钱的窗口。
#==============================================================================
class Window_BattleResult < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# exp : EXP
# gold : 金钱
# treasures : 宝物
#--------------------------------------------------------------------------
def initialize(exp, gold, treasures)
@exp = exp
@gold = gold
@treasures = treasures
super(160, 0, 320, @treasures.size * 32 + 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.y = 160 - height / 2
self.back_opacity = 255
self.visible = false
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
x = 4
self.contents.font.color = Color.new(0, 0, 0, 255)
cx = contents.text_size(@exp.to_s).width
self.contents.draw_text_s(x, 0, cx, 32, @exp.to_s)
x += cx + 4
self.contents.font.color = Color.new(0, 0, 0, 255)
cx = contents.text_size("经验").width
self.contents.draw_text_s(x, 0, 64, 32, "经验")
x += cx + 16
self.contents.font.color = Color.new(0, 0, 0, 255)
cx = contents.text_size(@gold.to_s).width
self.contents.draw_text_s(x, 0, cx, 32, @gold.to_s)
x += cx + 4
self.contents.font.color = Color.new(0, 0, 0, 255)
self.contents.draw_text_s(x, 0, 128, 32, $data_system.words.gold)
y = 32
for item in @treasures
draw_item_name(item, 4, y)
y += 32
end
end
end
复制代码
至于你说阴影位置的问题,应该是跟那个x-1y-1什么的有关吧……
作者:
moy
时间:
2010-10-3 07:58
def draw_text_s(x, y, width, height, str, align=0,inbattle = false) #增加inbattle变量
#在self.font.color.set(255, 255, 255)后一行插入
self.font.color.set(255, 155, 55) if inbattle #数值随便改的
end
复制代码
然后再结算调用的时候多加一个true就行
作者:
p7l8k90
时间:
2010-10-3 09:23
回复
moy
的帖子
那个,往哪加TRUE啊……
作者:
fux2
时间:
2010-10-3 10:07
本帖最后由 fux2 于 2010-10-3 10:11 编辑
回复
p7l8k90
的帖子
简单问题干啥复杂化?255,255,255那里就是改RGB验色,RED,GREEN,BLUE知道啵?临时更改可以把255换成全局参数,比如$R,$G,$B,在原draw_text方法里添加默认值,\C[n]用法里定义变量值。
作者:
p7l8k90
时间:
2010-10-3 10:09
本帖最后由 p7l8k90 于 2010-10-3 10:24 编辑
回复
fux2
的帖子
是,我知道,我想临时改,怎么改,不是全局都要黑色阴影,就战斗结算要其他时刻均为白色阴影,描边一样需要有多处改动。
汗……我能不能像Window_Base里一样,单独定义几种特殊状态下的颜色?那里面有这么几句
#--------------------------------------------------------------------------
# ● 获取普通文字色
#--------------------------------------------------------------------------
def normal_color
return Color.new(66, 121, 8, 255)
end
#--------------------------------------------------------------------------
# ● 获取无效文字色
#--------------------------------------------------------------------------
def disabled_color
return Color.new(255, 255, 255, 128)
end
#--------------------------------------------------------------------------
# ● 获取系统文字色
#--------------------------------------------------------------------------
def system_color
return Color.new(0, 255, 234, 255)
end
#--------------------------------------------------------------------------
# ● 获取危机文字色
#--------------------------------------------------------------------------
def crisis_color
return Color.new(255, 255, 64, 255)
end
#--------------------------------------------------------------------------
# ● 获取战斗不能文字色
#--------------------------------------------------------------------------
def knockout_color
return Color.new(255, 64, 0)
end
复制代码
如果我想用同样的方法定义文字描边该怎么做呢?
作者:
fux2
时间:
2010-10-3 10:26
回复
p7l8k90
的帖子
在这些句子下面给变量赋值。
作者:
p7l8k90
时间:
2010-10-3 13:43
回复
fux2
的帖子
……不明白……
作者:
goahead
时间:
2010-10-3 15:59
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1