| 赞 | 5 |
| VIP | |
| 好人卡 | |
| 积分 | 39 |
| 经验 | |
| 最后登录 | 2026-8-3 |
| 在线时间 | 1899 小时 |
- 梦石
- 0
- 星屑
- 3850
- 在线时间
- 1899 小时
- 注册时间
- 2010-6-19
- 回帖
- 917
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
如何把这个窗口皮肤描绘,放到下面的文本显示脚本里
[fold=draw_windowskin]#==============================================================================
# ** RPG::Cache 高速缓存UI
#==============================================================================
module RPG::Cache
def self.ui(filename)
self.load_bitmap("Graphics/Windowskins/", filename)
end
end
#==============================================================================
# ** Bitmap 拓展
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# * draw_windowskin 描绘窗口皮肤
# window_x 窗口X坐标 默认0
# window_Y 窗口Y坐标 默认0
# window_width 窗口width 默认self.width
# window_height 窗口height 默认self.height
#--------------------------------------------------------------------------
def draw_windowskin(window_x = 0, window_y = 0, window_width = self.width, window_height = self.height)
src_bitmap = RPG::Cache.ui("帮助窗口背景")
src_rect = Rect.new(0, 0, 0, 0)
dest_rect = Rect.new(0, 0, 0, 0)
# 上
src_rect.set(0, 0, 5, 5)
self.blt(window_x, window_y, src_bitmap, src_rect)
src_rect.set(6, 0, 5, 5)
self.blt(window_x + window_width - 5, window_y, src_bitmap, src_rect)
dest_rect.set(window_x + 5, window_y, window_width - 10, 5)
src_rect.set(5, 0, 1, 5)
self.stretch_blt(dest_rect, src_bitmap, src_rect)
# 下
src_rect.set(0, 6, 5, 5)
self.blt(window_x, window_y + window_height - 5, src_bitmap, src_rect)
src_rect.set(6, 6, 5, 5)
self.blt(window_x + window_width - 5, window_y + window_height - 5, src_bitmap, src_rect)
dest_rect.set(window_x + 5, window_y + window_height - 5, window_width - 10, 5)
src_rect.set(5, 6, 1, 5)
self.stretch_blt(dest_rect, src_bitmap, src_rect)
# 其余
dest_rect.set(window_x, window_y + 5, 5, window_height - 10)
src_rect.set(0, 5, 5, 1)
self.stretch_blt(dest_rect, src_bitmap, src_rect)
dest_rect.set(window_x + window_width - 5, window_y + 5, 5, window_height - 10)
src_rect.set(6, 5, 5, 1)
self.stretch_blt(dest_rect, src_bitmap, src_rect)
dest_rect.set(window_x + 5, window_y + 5, window_width - 10, window_height - 10)
src_rect.set(5, 5, 1, 1)
self.stretch_blt(dest_rect, src_bitmap, src_rect)
end
end[/fold]
[fold]#Graphics.tips(“你要说的话”, x = 0, y = 0, color = Color.new(238, 255, 64))
#==============================================================================
# ■ 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(238, 255, 64))
y = (640 - Tips_height) / 2 - 132 if y == 0
x = (480 - 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 = 25
@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 = 9999
@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[/fold] |
|