| 赞 | 95 |
| VIP | |
| 好人卡 | |
| 积分 | 18 |
| 经验 | |
| 最后登录 | 2025-11-14 |
| 在线时间 | 2527 小时 |
- 梦石
- 0
- 星屑
- 1816
- 在线时间
- 2527 小时
- 注册时间
- 2010-10-12
- 回帖
- 1336

|
发表于 2015-4-4 01:18:25
|
显示全部楼层
本帖最后由 刺夜之枪 于 2015-4-3 12:22 编辑
[pre lang="ruby"]#==============================================================================
# ■ Graphics
#------------------------------------------------------------------------------
# 可以#提示所有文本,支持所有场景显示。
#------------------------------------------------------------------------------
# 作者:你最珍贵 #
# 日期:2014-4-5 17:23
# 使用方法:Graphics.tips("")
# 版权说明:转载请保留作者信息,谢谢。
#==============================================================================
class << Graphics
#--------------------------------------------------------------------------
# ● 常量定义
#--------------------------------------------------------------------------
Tips_width = 640 # 底图宽度
Tips_height = 32 # 底图高度
Tips_ShowTime = 60 # 显示时间(最小35,最大不限)
Tips_Color = Color.new(0,0,0,220) # 底图颜色
#---------------------------------------------------------------------------
# ● 提示文本
#---------------------------------------------------------------------------
def tips(text, x = 0, y = 0, color = Color.new(255, 255, 255))
y = 350-120#(800 - Tips_height) / 2 - 132 if y == 0
x = 0#(600 - Tips_width) / 2 if x == 0
tips_create_bitmap(x, y)
tips_draw_text(text, color)
@tips_sprite.opacity = 255
@tips_time = Tips_ShowTime
end
#---------------------------------------------------------------------------
# ● 提示文本
#---------------------------------------------------------------------------
def tips_draw_text(text, color)
@tips_bitmap.font.size = 18
@tips_bitmap.font.color = color
cw = @tips_bitmap.text_size(text).width
@tips_bitmap.fill_rect(0,0,Tips_width, Tips_height,Tips_Color)
@tips_bitmap.draw_text(0,0,Tips_width,Tips_height,text,1)
end
#---------------------------------------------------------------------------
# ● 创建精灵位图
#---------------------------------------------------------------------------
def tips_create_bitmap(x, y)
if @tips_sprite.nil? or @tips_sprite.disposed?
@tips_sprite = Sprite.new
@tips_sprite.z = 0
@tips_bitmap = Bitmap.new(Tips_width, Tips_height)
@tips_sprite.bitmap = @tips_bitmap
end
@tips_sprite.x, @tips_sprite.y = x, y
end
#---------------------------------------------------------------------------
# ● 刷新提示信息
#---------------------------------------------------------------------------
alias tips_update update
def update
tips_update
unless @tips_sprite.nil? or @tips_sprite.disposed?
if @tips_time and @tips_time > 0
@tips_sprite.opacity -= 8 if @tips_time <= 35
@tips_time -= 1
end
end
end
end
[/pre]
这个是显示一个短的提示在地图中间的脚本,很快就消失了
|
|