赞 | 58 |
VIP | 37 |
好人卡 | 59 |
积分 | 12 |
经验 | 66255 |
最后登录 | 2023-5-29 |
在线时间 | 1017 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1232
- 在线时间
- 1017 小时
- 注册时间
- 2011-4-30
- 帖子
- 1516
|
不知道怎么处理所以就直接把这个东西从 $game_system里分出来了。方法:额,$zimu.credit_start()等- #==============================================================================
- # ■ 地图式 可传递触发事件 字幕滚动 V1.0版 (By TERENCE龙皇)
- #------------------------------------------------------------------------------
- # 使用效果:
- # (1) 可以配合地图上的事件或某些特效处理
- # (2) 字幕滚动的效果永远会显示在最前面
- # (3) 字幕滚动中,能侦测到事件的传递,藉此触发可以处理一些事情与特效
- #
- # 如何使用:
- # (1) 字幕使用 UTF-8 格式的 TXT 档传写,请放在 Credit 文件夹之下
- # (2) TXT 档名,请使用英文,才不会导致不同语言作业系统上读取失败
- # (3) 其他部分,详见发布帖子,或研究范例工程
- #==============================================================================
- CREDIT_DETECTE_Y = 240 # 触发侦测线
- CREDIT_NONEVISIBLE_HEIGHT = 25 # 字幕上下两侧不可视区域
- #==============================================================================
- # ■ Game_System
- #------------------------------------------------------------------------------
- # 处理系统附属资料的类别。(扩增字幕)
- # 本类别的实例请参考 。
- #==============================================================================
- class Zimu
- #--------------------------------------------------------------------------
- # ● 定义实例变数
- #--------------------------------------------------------------------------
- attr_accessor :credit_obj # 字幕物件暂存
- attr_accessor :credit_working # 字幕执行中的标志
- attr_accessor :credit_filename # 读取字幕的TXT档名
- #--------------------------------------------------------------------------
- # ● 初始化物件
- #--------------------------------------------------------------------------
- def initialize
- @credit_working = false
- @credit_filename = ""
- end
- #--------------------------------------------------------------------------
- # ● 字幕启用
- #--------------------------------------------------------------------------
- def credit_start(filename)
- @credit_working = true
- @credit_filename = "Credit/#{filename}.txt"
- end
- #--------------------------------------------------------------------------
- # ● 字幕取消
- #--------------------------------------------------------------------------
- def credit_canceled
- if @credit_working
- @credit_obj.y = -(@credit_obj.bitmap_hieght)
- end
- end
- #--------------------------------------------------------------------------
- # ● 字幕讯息事件是否被传递
- #--------------------------------------------------------------------------
- def credit_mesgpost?
- # 若启动字幕滚动
- if @credit_working
- # 侦测字幕滚动是否有事件被触发
- if @credit_obj.message_flag
- @credit_obj.message_flag = false
- return true
- else; return false; end
- else; return false; end
- end
- end
- #==============================================================================
- # ■ Sprite_Credit
- #------------------------------------------------------------------------------
- # 显示字幕滚动用的活动区块。监视 $game_system 丶活动区块状态
- # 自动变化。
- #==============================================================================
- class Sprite_Credit < Sprite
- #--------------------------------------------------------------------------
- # ● 定义实例变数
- #--------------------------------------------------------------------------
- attr_accessor :message_flag # 讯息标志
- attr_accessor :bitmap_hieght # 字幕高
- #--------------------------------------------------------------------------
- # ● 初始化物件
- #--------------------------------------------------------------------------
- def initialize(viewport)
- super(viewport)
- self.x = 0
- self.y = 430
- self.z = 0
- @new_bitmap_flag = false
- @line_counts = 0
- @bitmap_hieght = 0
- @message_line = []
- @message_flag = false
- update
- end
- #--------------------------------------------------------------------------
- # ● 字幕 Bitmap 初始建立
- #--------------------------------------------------------------------------
- def create(filename)
- unless FileTest.exist?(filename)
- $zimu.credit_working = false
- @new_bitmap_flag = false
- @line_counts = 0
- return
- end
- @bitmap_hieght = File.read(filename).count("\n")
- @bitmap_hieght = 32*(1+@bitmap_hieght)
- self.bitmap = Bitmap.new(640, @bitmap_hieght)
- File.open(filename) do |file|
- while line = file.gets
- dump_lines(line)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● TXT 文件 行处理
- #--------------------------------------------------------------------------
- def dump_lines(line)
- yy = 32*@line_counts
- if (line.gsub!(/\<PostMessage\>/){""})!=nil
- @message_line.push(yy+self.y)
- end
- if @line_counts == 0
- self.bitmap.draw_text(0, yy, 640, 32, line[3, line.size], 1)
- else
- self.bitmap.draw_text(0, yy, 640, 32, line, 1)
- end
- @line_counts += 1
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- # 设定计时器执行中为可见
- self.visible = $zimu.credit_working
- # 若启动字幕滚动
- if $zimu.credit_working
- unless @new_bitmap_flag
- @new_bitmap_flag = true
- create($zimu.credit_filename)
- end
- scroll_update
- message_detected
- end
- end
- #--------------------------------------------------------------------------
- # ● 字幕滚动
- #--------------------------------------------------------------------------
- def scroll_update
- if scroll_end?
- $zimu.credit_working = false
- @new_bitmap_flag = false
- @message_flag = false
- @message_line.clear
- @line_counts = 0
- self.y = 430
- if self.bitmap != nil
- self.bitmap.dispose
- end
- else
- self.y -= 1
- end
- end
- #--------------------------------------------------------------------------
- # ● 字幕滚动结束 ?
- #--------------------------------------------------------------------------
- def scroll_end?
- if self.y <= -(@bitmap_hieght)
- return true
- else
- return false
- end
- end
- #--------------------------------------------------------------------------
- # ● 事件讯息祯测
- #--------------------------------------------------------------------------
- def message_detected
- for i in 0...@message_line.size
- if @message_line[i] == nil; break; end
- @message_line[i] -= 1
- if @message_line[i] <= CREDIT_DETECTE_Y-32 # 触发侦测线
- @message_line.delete_at(i)
- @message_flag = true
- end
- end
- end
- end
- #==============================================================================
- # ■ Spriteset_Map
- #------------------------------------------------------------------------------
- # 处理地图画面活动区块和元件的类别。 (扩增字幕)
- # 本类别在 Scene_Map 类别的内部使用。
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ● 初始化物件
- #--------------------------------------------------------------------------
- alias original_initialize initialize
- def initialize
- # 字幕尚未启动才 生成
- unless $zimu.credit_working
- hh = CREDIT_NONEVISIBLE_HEIGHT
- credit_viewport = Viewport.new(0,hh,640,480-hh*2)
- credit_viewport.z = 5000 + 200
- $zimu.credit_obj = Sprite_Credit.new(credit_viewport)
- end
- original_initialize
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- alias original_dispose dispose
- def dispose
- # 场景非地图 字幕滚动区块可视关闭
- unless $scene.is_a?(Scene_Map)
- $zimu.credit_obj.visible = false
- end
- # 字幕尚未启动才 释放字幕滚动区块
- unless $zimu.credit_working
- # 释放显示连接埠
- $zimu.credit_obj.viewport.dispose
- $zimu.credit_obj.dispose
- end
- original_dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- alias original_update update
- def update
- # 更新字幕滚动区块
- $zimu.credit_obj.update
- # 更新显示连接埠
- $zimu.credit_obj.viewport.update
- original_update
- end
- end
- $zimu= Zimu.new
复制代码 |
评分
-
查看全部评分
|