赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 8559 |
最后登录 | 2015-8-26 |
在线时间 | 439 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 439 小时
- 注册时间
- 2013-3-2
- 帖子
- 710
|
- #==============================================================================
- # ■ 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
复制代码 该脚本来源:
@你最珍贵 |
评分
-
查看全部评分
|