Project1
标题:
任意调用即时消息
[打印本页]
作者:
mariofans
时间:
2015-7-8 19:23
标题:
任意调用即时消息
本帖最后由 mariofans 于 2015-7-10 10:28 编辑
写了这个小玩意,也是从6R随便找到的脚本里面改良出来的。
可以实现渐变消息和移动消息,具体见范例。
范例里面只给了从上往下拉,在地图上调用,
其实也可以实现从下往上拉(两个速度都写负的),在任何Scene里都可以调用。
给了一套默认模板,默认模板可以根据自己喜好改,也可以在调用的时候改写模板。
利用全局变量去除了F12出错的BUG
经测试,XP,VX,VA都可正常调用。
(写的很蠢,也不简便,反正只要能用就行了嘛= =|||)
#==============================================================================
# ■ Graphics
#------------------------------------------------------------------------------
# 可以提示所有文本,支持所有场景显示。
#------------------------------------------------------------------------------
# 作者:你最珍贵
# 修改者:马里奥收藏家
#
# 日期:2015-7-8
#
# 使用方法:Graphics.tips("")
#
# 版权说明:转载请保留作者信息,谢谢。
#==============================================================================
class << Graphics
#--------------------------------------------------------------------------
# ● 常量定义
#
# 速度什么的可以是正数也可以是负数(负数就是相反效果)。
# 方式除了1和2不要填其它的,否则无效。
# 移动范围既可以指坐标的改变范围也可以指不透明度的改变范围。
# 速度既可以指坐标的改变速度也可以指不透明度的改变速度。
# 出现的速度和消失的速度可以不同步。
# 要改颜色的话两个颜色都必须填,不能写nil。
#
#--------------------------------------------------------------------------
Tips_x = 0 # 默认位置
Tips_y = 0 # 默认位置
Tips_width = 640 # 底图宽度
Tips_height = 32 # 底图高度
Tips_Color = Color.new(0,0,0,180) # 底图颜色
Tips_FontColor = Color.new(255,255,255,255) # 文字颜色
Tips_type = 1 # 显示方式
#(1移动2淡入淡出)
Tips_opacity = 255 # 底图透明
Tips_ShowTime = 1 # 显示速度
Tips_StopTime = 60 # 停留时间
Tips_HideTime = 1 # 消失速度
Tips_MoveSpace = 32 # 移动范围
#---------------------------------------------------------------------------
# ● 提示文本
#---------------------------------------------------------------------------
def tips(text,x=nil,y=nil,opacity=nil,type=nil,show=nil,stop=nil,hide=nil,space=nil,color=Tips_FontColor,backcolor=Tips_Color)
x = Tips_x if x == nil
y = Tips_y if y == nil
opacity = Tips_opacity if opacity == nil
@tips_type = type if type != nil
@tips_type = Tips_type if type == nil
@tips_space = space if space != nil
@tips_space = Tips_MoveSpace if space == nil
@tips_showtime = show if show != nil
@tips_showtime = Tips_ShowTime if show == nil
@tips_stoptime = stop if stop != nil
@tips_stoptime = Tips_StopTime if stop == nil
@tips_hidetime = hide if hide != nil
@tips_hidetime = Tips_HideTime if hide == nil
tips_create_bitmap(x,y,opacity)
tips_draw_text(text,color,backcolor)
@tips_ox = x
@tips_oy = y
@tips_ax = x
@tips_ay = y - @tips_space
@tips_ay = y + @tips_space if @tips_showtime < 0
@tips_oo = opacity
@tips_ao = opacity + @tips_space
@tips_ao = opacity - @tips_space if @tips_showtime < 0
case @tips_type
when 1
@tips_stage = 1
when 2
@tips_stage = 11
end
end
#---------------------------------------------------------------------------
# ● 提示文本
#---------------------------------------------------------------------------
def tips_draw_text(text,color,backcolor)
@tips_bitmap.font.size = 22
@tips_bitmap.font.color = color
cw = @tips_bitmap.text_size(text).width
@tips_bitmap.fill_rect(0,0,Tips_width, Tips_height,backcolor)
@tips_bitmap.draw_text(0,0,Tips_width,Tips_height,text,1)
end
#---------------------------------------------------------------------------
# ● 创建精灵位图
#---------------------------------------------------------------------------
def tips_create_bitmap(x,y,opacity)
if @tips_sprite.nil? or @tips_sprite.disposed?
@tips_sprite = Sprite.new
@tips_sprite.z = 600
@tips_bitmap = Bitmap.new(Tips_width,Tips_height)
@tips_sprite.bitmap = @tips_bitmap
end
@tips_sprite.x = x
case @tips_type
when 1
@tips_sprite.y = y - @tips_space
@tips_sprite.y = y + @tips_space if @tips_showtime < 0
when 2
@tips_sprite.y = y
end
@tips_sprite.opacity = opacity
end
#---------------------------------------------------------------------------
# ● 刷新提示信息
#---------------------------------------------------------------------------
alias tips_update update unless $Graphics_Tips_Script_Used
def update
tips_update
unless @tips_sprite.nil? or @tips_sprite.disposed?
case @tips_stage
when 1
if @tips_showtime > 0
@tips_sprite.y += @tips_showtime if @tips_sprite.y < @tips_oy
@tips_stage += 1 if @tips_sprite.y >= @tips_oy
elsif @tips_showtime < 0
@tips_sprite.y += @tips_showtime if @tips_sprite.y > @tips_oy
@tips_stage += 1 if @tips_sprite.y <= @tips_oy
else
@tips_sprite.y = @tips_oy
@tips_stage += 1
end
when 2
if @tips_stoptime and @tips_stoptime > 0
@tips_stoptime -= 1
@tips_stage += 1 if @tips_stoptime <= 0
end
when 3
if @tips_hidetime > 0
@tips_sprite.y -= @tips_showtime if @tips_sprite.y > @tips_ay
@tips_stage += 1 if @tips_sprite.y <= @tips_ay
elsif @tips_hidetime < 0
@tips_sprite.y -= @tips_showtime if @tips_sprite.y < @tips_ay
@tips_stage += 1 if @tips_sprite.y >= @tips_ay
else
@tips_sprite.y = @tips_ay
@tips_stage += 1
end
when 4
@tips_sprite.dispose
@tips_stage = 0
when 11
if @tips_showtime > 0
@tips_sprite.opacity += @tips_showtime if @tips_sprite.opacity < @tips_ao
@tips_stage += 1 if @tips_sprite.opacity >= @tips_ao
elsif @tips_showtime < 0
@tips_sprite.opacity += @tips_showtime if @tips_sprite.opacity > @tips_ao
@tips_stage += 1 if @tips_sprite.opacity <= @tips_ao
else
@tips_sprite.opacity = @tips_ao
@tips_stage += 1
end
when 12
if @tips_stoptime and @tips_stoptime > 0
@tips_stoptime -= 1
@tips_stage += 1 if @tips_stoptime <= 0
end
when 13
if @tips_hidetime > 0
@tips_sprite.opacity -= @tips_hidetime if @tips_sprite.opacity > @tips_oo
@tips_stage += 1 if @tips_sprite.opacity <= @tips_oo
elsif @tips_hidetime < 0
@tips_sprite.opacity -= @tips_hidetime if @tips_sprite.opacity < @tips_oo
@tips_stage += 1 if @tips_sprite.opacity >= @tips_oo
else
@tips_sprite.opacity = @tips_oo
@tips_stage += 1
end
when 14
@tips_sprite.dispose
@tips_stage = 0
end
end
end
end
$Graphics_Tips_Script_Used = true
复制代码
范例:pan.baidu.com/s/1c0IwdWW
作者:
怪蜀黍
时间:
2015-7-9 08:51
本帖最后由 怪蜀黍 于 2015-7-9 16:24 编辑
请补充注明原脚本来源喵
召唤
@你最珍贵
求问来源喵呜
作者:
你最珍贵
时间:
2015-7-9 21:04
怎么变得这么长了。。。
作者:
chd114
时间:
2015-7-9 21:08
这不是橙光。。。如果无法提供来源你就不要写改编。。。之前在素材区就被坑了一把。。。因为背景bg无法给出提取的游戏就被开水了
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1