Project1
标题:
地图上播放的动画会漂移……
[打印本页]
作者:
水镜风生
时间:
2008-8-9 02:41
标题:
地图上播放的动画会漂移……
在下最近打算做一个比较简单那的ARPG,在制作过程中遇到了一个比较囧问题,
如下图所示:
图中主角和怪物中间的那个是爆炸动画,本来是播放在怪物身上的,但因为主角向右移动
导致画面向右滚动,结果动画也跟着漂移了……
虽然在下也略懂一点脚本,但未接触过有关animation的类,无从入手……
希望各位能解囊(时间囊)相助,不胜感激!
作者:
kissye
时间:
2008-8-9 02:57
提示:
作者被禁止或删除 内容自动屏蔽
作者:
火鸡三毛老大
时间:
2008-8-9 02:59
#==============================================================================
# ■ [VX_非官方补丁]地图动画显示修正 for VX1.02 —— 作者:诡异の猫
#------------------------------------------------------------------------------
# 注意: 此补丁为VX1.02专用!
#------------------------------------------------------------------------------
# 补丁内容: 彻底修正地图上播放动画(以画面为中心除外),动画跟随画面移动问题。
# [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
复制代码
地图显示动画修正补丁…… [LINE]1,#dddddd[/LINE]
系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~
作者:
越前リョーマ
时间:
2008-8-9 03:04
那个血条……好面熟啊……
话说不是有官方补丁修复了么……
作者:
火鸡三毛老大
时间:
2008-8-9 03:12
以下引用
越前リョーマ于2008-8-8 19:04:37
的发言:
那个血条……好面熟啊……
话说不是有官方补丁修复了么……
官方修复不彻底……
那个血条当然面熟……
就是你悬赏……
记得是 沉影不器 写的……
不是 沉影 就是柳之一……
作者:
水镜风生
时间:
2008-8-9 16:10
感谢LS几位,问题已解决。
话说那个血条是我自己写的说,虽然外观上仿照了夜想曲……
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1