赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 3 |
经验 | 13852 |
最后登录 | 2022-10-15 |
在线时间 | 286 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 265
- 在线时间
- 286 小时
- 注册时间
- 2009-11-7
- 帖子
- 55
|
多动画叠加效果 v1.0和地图动画显示修正 for VX1.02 发生冲突,两个脚本一起多个动画会失效,不管哪个放在前面,我试过合并过但没有成功 求帮忙- #==============================================================================
- # ■ [VX_非官方补丁]地图动画显示修正 for VX1.02 —— 原著:诡异の猫
- # 针对VX1.02整合:公孙鸿剑[UNIR工作室]
- #------------------------------------------------------------------------------
- # 注意: 此补丁为VX1.02专用!针对VX1.01的版本请到rpg.blue自己找。
- #------------------------------------------------------------------------------
- # 补丁内容: 彻底修正地图上播放动画(以画面为中心除外),动画跟随画面移动问题。
- # [Enterbrain对这个问题的修复不彻底]
- #==============================================================================
- class Sprite_Base < Sprite
- #--------------------------------------------------------------------------
- # ● 类变量
- #--------------------------------------------------------------------------
- @@animations = []
- @@_reference_count = {}
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # viewport : 视区
- #--------------------------------------------------------------------------
- def initialize(viewport = nil)
- super(viewport)
- @use_sprite = true # 活动块使用的标志
- @animation_duration = 0 # 动画剩余时间
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- dispose_animation
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- if @animation != nil
- @animation_duration -= 1
- if @animation_duration % 4 == 0
- update_animation
- end
- end
- @@animations.clear
- end
- #--------------------------------------------------------------------------
- # ● 判断动画是否正在显示
- #--------------------------------------------------------------------------
- def animation?
- return @animation != nil
- end
- #--------------------------------------------------------------------------
- # ● 开始播放动画
- #--------------------------------------------------------------------------
- def start_animation(animation, mirror = false)
- dispose_animation
- @animation = animation
- return if @animation == nil
- @animation_mirror = mirror
- @animation_duration = @animation.frame_max * 4 + 1
- load_animation_bitmap
- @animation_sprites = []
- if @animation.position != 3 or not @@animations.include?(animation)
- if @use_sprite
- for i in 0..15
- sprite = ::Sprite.new(viewport)
- sprite.visible = false
- @animation_sprites.push(sprite)
- end
- unless @@animations.include?(animation)
- @@animations.push(animation)
- end
- end
- end
- if @animation.position == 3
- if viewport == nil
- @animation_ox = 544 / 2 ##
- @animation_oy = 416 / 2 ##
- else
- @animation_ox = viewport.rect.width / 2
- @animation_oy = viewport.rect.height / 2
- end
- else
- @animation_ox = x - ox + width / 2
- @animation_oy = y - oy + height / 2
- if @animation.position == 0
- @animation_oy -= height / 2
- elsif @animation.position == 2
- @animation_oy += height / 2
- end
- end
- update_animation
- end
- #--------------------------------------------------------------------------
- # ● 读取动画图像
- #--------------------------------------------------------------------------
- def load_animation_bitmap
- animation1_name = @animation.animation1_name
- animation1_hue = @animation.animation1_hue
- animation2_name = @animation.animation2_name
- animation2_hue = @animation.animation2_hue
- @animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
- @animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
- if @@_reference_count.include?(@animation_bitmap1)
- @@_reference_count[@animation_bitmap1] += 1
- else
- @@_reference_count[@animation_bitmap1] = 1
- end
- if @@_reference_count.include?(@animation_bitmap2)
- @@_reference_count[@animation_bitmap2] += 1
- else
- @@_reference_count[@animation_bitmap2] = 1
- end
- Graphics.frame_reset
- end
- #--------------------------------------------------------------------------
- # ● 释放动画
- #--------------------------------------------------------------------------
- def dispose_animation
- if @animation_bitmap1 != nil
- @@_reference_count[@animation_bitmap1] -= 1
- if @@_reference_count[@animation_bitmap1] == 0
- @animation_bitmap1.dispose
- end
- end
- if @animation_bitmap2 != nil
- @@_reference_count[@animation_bitmap2] -= 1
- if @@_reference_count[@animation_bitmap2] == 0
- @animation_bitmap2.dispose
- end
- end
- if @animation_sprites != nil
- for sprite in @animation_sprites
- sprite.dispose
- end
- @animation_sprites = nil
- @animation = nil
- end
- @animation_bitmap1 = nil
- @animation_bitmap2 = nil
- end
- #--------------------------------------------------------------------------
- # ● 更新动画
- #--------------------------------------------------------------------------
- def update_animation
- if @animation_duration > 0
- frame_index = @animation.frame_max - (@animation_duration + 3) / 4
- animation_set_sprites(@animation.frames[frame_index])
- for timing in @animation.timings
- if timing.frame == frame_index
- animation_process_timing(timing)
- end
- end
- else
- dispose_animation
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置动画活动块
- # frame : 画面数据 (RPG::Animation::Frame)
- #--------------------------------------------------------------------------
- def animation_set_sprites(frame)
- cell_data = frame.cell_data
- for i in 0..15
- sprite = @animation_sprites[i]
- next if sprite == nil
- pattern = cell_data[i, 0]
- if pattern == nil or pattern == -1
- sprite.visible = false
- next
- end
- if pattern < 100
- sprite.bitmap = @animation_bitmap1
- else
- sprite.bitmap = @animation_bitmap2
- end
- sprite.visible = true
- sprite.src_rect.set(pattern % 5 * 192,
- pattern % 100 / 5 * 192, 192, 192)
- #诡异之猫的地图动画显示修正(PART1) 开始
- position = @animation.position
- if position == 3
- if self.viewport != nil
- sprite.x = self.viewport.rect.width / 2
- sprite.y = self.viewport.rect.height / 2
- else
- sprite.x = 272
- sprite.y = 208
- end
- else
- sprite.x = self.x - self.ox + self.src_rect.width / 2
- sprite.y = self.y - self.oy + self.src_rect.height / 2
- sprite.y -= self.src_rect.height / 2 if position == 0
- sprite.y += self.src_rect.height / 2 if position == 2
- end
- if @animation_mirror
- sprite.x -= cell_data[i, 1]
- sprite.y += cell_data[i, 2]
- sprite.angle = (360 - cell_data[i, 4])
- sprite.mirror = (cell_data[i, 5] == 0)
- else
- sprite.x += cell_data[i, 1]
- sprite.y += cell_data[i, 2]
- sprite.angle = cell_data[i, 4]
- sprite.mirror = (cell_data[i, 5] == 1)
- end
- sprite.z = self.z + 300 + i
- sprite.ox = 96
- sprite.oy = 96
- sprite.zoom_x = cell_data[i, 3] / 100.0
- sprite.zoom_y = cell_data[i, 3] / 100.0
- sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
- sprite.blend_type = cell_data[i, 7]
- end
- #诡异之猫的地图动画显示修正(PART1) 结束
- end
- #--------------------------------------------------------------------------
- # ● SE 与闪烁时间处理
- # timing : 时间数据 (RPG::Animation::Timing)
- #--------------------------------------------------------------------------
- def animation_process_timing(timing)
- timing.se.play
- case timing.flash_scope
- when 1
- self.flash(timing.flash_color, timing.flash_duration * 4)
- when 2
- if viewport != nil
- viewport.flash(timing.flash_color, timing.flash_duration * 4)
- end
- when 3
- self.flash(nil, timing.flash_duration * 4)
- end
- end
- #--------------------------------------------------------------------------
- # ● 诡异之猫的地图动画显示修正(PART2)
- #--------------------------------------------------------------------------
- def x=(x)
- sx = x - self.x
- if sx != 0
- if @animation_sprites != nil
- for i in 0..15
- @animation_sprites[i].x += sx
- end
- end
- end
- super
- end
- def y=(y)
- sy = y - self.y
- if sy != 0
- if @animation_sprites != nil
- for i in 0..15
- @animation_sprites[i].y += sy
- end
- end
- end
- super
- end
- end
复制代码- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
- #==============================================================================
- # ■ Sprite_Base
- #------------------------------------------------------------------------------
- # 处理动画显示追加活动块的类变量。
- #==============================================================================
- class Sprite_Base < Sprite
- #--------------------------------------------------------------------------
- # ● 类变量
- # @@animations 用来记录动画正在播放,防止同一时间多次在同位置播放全屏动画
- # @@_reference_count 用来记录哪些素材正在被使用
- #--------------------------------------------------------------------------
- @@animations = []
- @@_reference_count = {}
- #--------------------------------------------------------------------------
- # ● done 初始化对像
- # viewport : 视口
- #--------------------------------------------------------------------------
- def initialize(viewport = nil)
- super(viewport)
- @use_sprite = true # 活动块使用标记
- @animation_duration = 0 # 动画剩余时间
- # 基本结构:animation, mirror, length, sprites, ox, oy ,[bitmap1, bitmap2]
- @animation_collection = []
- end
- #--------------------------------------------------------------------------
- # ● done 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- return if @animation_collection == nil
- for ani in @animation_collection
- dispose_animation(ani)
- end
- end
- #--------------------------------------------------------------------------
- # ● done 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- if @animation_collection != nil
- @animation_duration -= 1
- for ani in @animation_collection
- ani[2] -= 1
- if ani[2] % 4 == 0
- update_animation(ani)
- end
- end
- end
- @@animations.clear
- end
- #--------------------------------------------------------------------------
- # ● done 动画显示中判定
- #--------------------------------------------------------------------------
- def animation?
- return @animation_collection != nil
- end
- #--------------------------------------------------------------------------
- # ● done 开始动画
- #--------------------------------------------------------------------------
- def start_animation(animation, mirror = false)
- @animation = animation
- return if @animation == nil
- @animation_mirror = mirror
- animation_length = @animation.frame_max * 4 + 1
- @animation_duration += animation_length
- animbitmap = load_animation_bitmap
- @animation_sprites = []
- if @animation.position != 3 or not @@animations.include?(animation)
- if @use_sprite
- for i in 0..15
- sprite = ::Sprite.new(viewport)
- sprite.visible = false
- @animation_sprites.push(sprite)
- end
- unless @@animations.include?(animation)
- @@animations.push(animation)
- end
- end
- end
- if @animation.position == 3
- if viewport == nil
- @animation_ox = 544 / 2
- @animation_oy = 416 / 2
- else
- @animation_ox = viewport.rect.width / 2
- @animation_oy = viewport.rect.height / 2
- end
- else
- @animation_ox = x - ox + width / 2
- @animation_oy = y - oy + height / 2
- if @animation.position == 0
- @animation_oy -= height / 2
- elsif @animation.position == 2
- @animation_oy += height / 2
- end
- end
- @animation_collection.push([@animation, @animation_mirror, animation_length,
- @animation_sprites, @animation_ox, @animation_oy,
- animbitmap])
- end
- #--------------------------------------------------------------------------
- # ● done 读取动画的类变量
- #--------------------------------------------------------------------------
- def load_animation_bitmap
- animation1_name = @animation.animation1_name
- animation1_hue = @animation.animation1_hue
- animation2_name = @animation.animation2_name
- animation2_hue = @animation.animation2_hue
- @animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
- @animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
- if @@_reference_count.include?(@animation_bitmap1)
- @@_reference_count[@animation_bitmap1] += 1
- else
- @@_reference_count[@animation_bitmap1] = 1
- end
- if @@_reference_count.include?(@animation_bitmap2)
- @@_reference_count[@animation_bitmap2] += 1
- else
- @@_reference_count[@animation_bitmap2] = 1
- end
- Graphics.frame_reset
- return [@animation_bitmap1, @animation_bitmap2]
- end
- #--------------------------------------------------------------------------
- # ● done 释放动画
- #--------------------------------------------------------------------------
- def dispose_animation(ani)
- if ani[6][0] != nil
- @@_reference_count[ani[6][0]] -= 1
- if @@_reference_count[ani[6][0]] == 0
- ani[6][0].dispose
- end
- end
- if ani[6][1] != nil
- @@_reference_count[ani[6][1]] -= 1
- if @@_reference_count[ani[6][1]] == 0
- ani[6][1].dispose
- end
- end
- if ani[3] != nil
- for sprite in ani[3]
- sprite.dispose
- end
- @animation_sprites = nil
- @animation = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● done 刷新动画
- #--------------------------------------------------------------------------
- def update_animation(ani)
- if ani[2] > 0
- frame_index = ani[0].frame_max - (ani[2] + 3) / 4
- animation_set_sprites(ani[0].frames[frame_index], ani)
- for timing in ani[0].timings
- if timing.frame == frame_index
- animation_process_timing(timing)
- end
- end
- else
- dispose_animation(ani)
- end
- end
- #--------------------------------------------------------------------------
- # ● done 设置动画活动块
- # frame : 帧数据 (RPG::Animation::Frame)
- #--------------------------------------------------------------------------
- def animation_set_sprites(frame, ani)
- cell_data = frame.cell_data
- for i in 0..15
- sprite = ani[3][i]
- next if sprite == nil
- pattern = cell_data[i, 0]
- if pattern == nil or pattern == -1
- sprite.visible = false
- next
- end
- if pattern < 100
- sprite.bitmap = ani[6][0]
- else
- sprite.bitmap = ani[6][1]
- end
- sprite.visible = true
- sprite.src_rect.set(pattern % 5 * 192,
- pattern % 100 / 5 * 192, 192, 192)
- if @animation_mirror
- sprite.x = ani[4] - cell_data[i, 1]
- sprite.y = ani[5] - cell_data[i, 2]
- sprite.angle = (360 - cell_data[i, 4])
- sprite.mirror = (cell_data[i, 5] == 0)
- else
- sprite.x = ani[4] + cell_data[i, 1]
- sprite.y = ani[5] + cell_data[i, 2]
- sprite.angle = cell_data[i, 4]
- sprite.mirror = (cell_data[i, 5] == 1)
- end
- sprite.z = self.z + 300
- sprite.ox = 96
- sprite.oy = 96
- sprite.zoom_x = cell_data[i, 3] / 100.0
- sprite.zoom_y = cell_data[i, 3] / 100.0
- sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
- sprite.blend_type = cell_data[i, 7]
- end
- end
- #--------------------------------------------------------------------------
- # ● done SE 与闪烁的时机处理
- # timing : Timing数据 (RPG::Animation::Timing)
- #--------------------------------------------------------------------------
- def animation_process_timing(timing)
- timing.se.play
- case timing.flash_scope
- when 1
- self.flash(timing.flash_color, timing.flash_duration * 4)
- when 2
- if viewport != nil
- viewport.flash(timing.flash_color, timing.flash_duration * 4)
- end
- when 3
- self.flash(nil, timing.flash_duration * 4)
- end
- end
- end
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
复制代码 |
|