设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2017|回复: 5
打印 上一主题 下一主题

地图上播放的动画会漂移……

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
65
在线时间
433 小时
注册时间
2007-5-1
帖子
993
跳转到指定楼层
1
发表于 2008-8-9 02:41:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
在下最近打算做一个比较简单那的ARPG,在制作过程中遇到了一个比较囧问题,
如下图所示:



图中主角和怪物中间的那个是爆炸动画,本来是播放在怪物身上的,但因为主角向右移动
导致画面向右滚动,结果动画也跟着漂移了……

虽然在下也略懂一点脚本,但未接触过有关animation的类,无从入手……

希望各位能解囊(时间囊)相助,不胜感激!

嗯,不能浪费签名了,打广告。本人的悲剧作品:
坑化游戏《龙之影》      R剧《星空》     小游戏《剑与拳头》
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-7-8
帖子
466
2
发表于 2008-8-9 02:57:26 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

很傻很天真

梦石
0
星屑
55
在线时间
3 小时
注册时间
2007-3-13
帖子
3667
3
发表于 2008-8-9 02:59:55 | 只看该作者
  1. #==============================================================================
  2. # ■ [VX_非官方补丁]地图动画显示修正 for VX1.02    —— 作者:诡异の猫
  3. #------------------------------------------------------------------------------
  4. #    注意: 此补丁为VX1.02专用!
  5. #------------------------------------------------------------------------------
  6. #    补丁内容: 彻底修正地图上播放动画(以画面为中心除外),动画跟随画面移动问题。
  7. #              [Enterbrain对这个问题修正不彻底]
  8. #==============================================================================

  9. class Sprite_Base < Sprite
  10.   #--------------------------------------------------------------------------
  11.   # ● 类变量
  12.   #--------------------------------------------------------------------------
  13.   @@animations = []
  14.   @@_reference_count = {}
  15.   #--------------------------------------------------------------------------
  16.   # ● 初始化对象
  17.   #     viewport : 视窗
  18.   #--------------------------------------------------------------------------
  19.   def initialize(viewport = nil)
  20.     super(viewport)
  21.     @use_sprite = true          # 活动快使用的标志
  22.     @animation_duration = 0     # 动画剩余时间
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 释放
  26.   #--------------------------------------------------------------------------
  27.   def dispose
  28.     super
  29.     dispose_animation
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 刷新画面
  33.   #--------------------------------------------------------------------------
  34.   def update
  35.     super
  36.     if @animation != nil
  37.       @animation_duration -= 1
  38.       if @animation_duration % 4 == 0
  39.         update_animation
  40.       end
  41.     end
  42.     @@animations.clear
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 判断动画是否正在显示
  46.   #--------------------------------------------------------------------------
  47.   def animation?
  48.     return @animation != nil
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 开始播放动画
  52.   #--------------------------------------------------------------------------
  53.   def start_animation(animation, mirror = false)
  54.     dispose_animation
  55.     @animation = animation
  56.     return if @animation == nil
  57.     @animation_mirror = mirror
  58.     @animation_duration = @animation.frame_max * 4 + 1
  59.     load_animation_bitmap
  60.     @animation_sprites = []
  61.     if @animation.position != 3 or not @@animations.include?(animation)
  62.       if @use_sprite
  63.         for i in 0..15
  64.           sprite = ::Sprite.new(viewport)
  65.           sprite.visible = false
  66.           @animation_sprites.push(sprite)
  67.         end
  68.         unless @@animations.include?(animation)
  69.           @@animations.push(animation)
  70.         end
  71.       end
  72.     end
  73.     if @animation.position == 3
  74.       if viewport == nil
  75.         @animation_ox = 544 / 2 ##
  76.         @animation_oy = 416 / 2 ##
  77.       else
  78.         @animation_ox = viewport.rect.width / 2
  79.         @animation_oy = viewport.rect.height / 2
  80.       end
  81.     else
  82.       @animation_ox = x - ox + width / 2
  83.       @animation_oy = y - oy + height / 2
  84.       if @animation.position == 0
  85.         @animation_oy -= height / 2
  86.       elsif @animation.position == 2
  87.         @animation_oy += height / 2
  88.       end
  89.     end
  90.     update_animation
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 读取动画图像
  94.   #--------------------------------------------------------------------------
  95.   def load_animation_bitmap
  96.     animation1_name = @animation.animation1_name
  97.     animation1_hue = @animation.animation1_hue
  98.     animation2_name = @animation.animation2_name
  99.     animation2_hue = @animation.animation2_hue
  100.     @animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  101.     @animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  102.     if @@_reference_count.include?(@animation_bitmap1)
  103.       @@_reference_count[@animation_bitmap1] += 1
  104.     else
  105.       @@_reference_count[@animation_bitmap1] = 1
  106.     end
  107.     if @@_reference_count.include?(@animation_bitmap2)
  108.       @@_reference_count[@animation_bitmap2] += 1
  109.     else
  110.       @@_reference_count[@animation_bitmap2] = 1
  111.     end
  112.     Graphics.frame_reset
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● 释放动画
  116.   #--------------------------------------------------------------------------
  117.   def dispose_animation
  118.     if @animation_bitmap1 != nil
  119.       @@_reference_count[@animation_bitmap1] -= 1
  120.       if @@_reference_count[@animation_bitmap1] == 0
  121.         @animation_bitmap1.dispose
  122.       end
  123.     end
  124.     if @animation_bitmap2 != nil
  125.       @@_reference_count[@animation_bitmap2] -= 1
  126.       if @@_reference_count[@animation_bitmap2] == 0
  127.         @animation_bitmap2.dispose
  128.       end
  129.     end
  130.     if @animation_sprites != nil
  131.       for sprite in @animation_sprites
  132.         sprite.dispose
  133.       end
  134.       @animation_sprites = nil
  135.       @animation = nil
  136.     end
  137.     @animation_bitmap1 = nil
  138.     @animation_bitmap2 = nil
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● 更新动画
  142.   #--------------------------------------------------------------------------
  143.   def update_animation
  144.     if @animation_duration > 0
  145.       frame_index = @animation.frame_max - (@animation_duration + 3) / 4
  146.       animation_set_sprites(@animation.frames[frame_index])
  147.       for timing in @animation.timings
  148.         if timing.frame == frame_index
  149.           animation_process_timing(timing)
  150.         end
  151.       end
  152.     else
  153.       dispose_animation
  154.     end
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● 设置活动块
  158.   #     frame : 画面数据 (RPG::Animation::Frame)
  159.   #--------------------------------------------------------------------------
  160.   def animation_set_sprites(frame)
  161.     cell_data = frame.cell_data
  162.     for i in 0..15
  163.       sprite = @animation_sprites[i]
  164.       next if sprite == nil
  165.       pattern = cell_data[i, 0]
  166.       if pattern == nil or pattern == -1
  167.         sprite.visible = false
  168.         next
  169.       end
  170.       if pattern < 100
  171.         sprite.bitmap = @animation_bitmap1
  172.       else
  173.         sprite.bitmap = @animation_bitmap2
  174.       end
  175.       sprite.visible = true
  176.       sprite.src_rect.set(pattern % 5 * 192,
  177.         pattern % 100 / 5 * 192, 192, 192)
  178.       #诡异之猫的地图动画显示修正(PART1) 开始
  179.       position = @animation.position
  180.       if position == 3
  181.         if self.viewport != nil
  182.           sprite.x = self.viewport.rect.width / 2
  183.           sprite.y = self.viewport.rect.height / 2
  184.         else
  185.           sprite.x = 272
  186.           sprite.y = 208
  187.         end
  188.       else
  189.         sprite.x = self.x - self.ox + self.src_rect.width / 2
  190.         sprite.y = self.y - self.oy + self.src_rect.height / 2
  191.         sprite.y -= self.src_rect.height / 2 if position == 0
  192.         sprite.y += self.src_rect.height / 2 if position == 2
  193.       end
  194.       if @animation_mirror
  195.         sprite.x -= cell_data[i, 1]
  196.         sprite.y += cell_data[i, 2]
  197.         sprite.angle = (360 - cell_data[i, 4])
  198.         sprite.mirror = (cell_data[i, 5] == 0)
  199.       else
  200.         sprite.x += cell_data[i, 1]
  201.         sprite.y += cell_data[i, 2]
  202.         sprite.angle = cell_data[i, 4]
  203.         sprite.mirror = (cell_data[i, 5] == 1)
  204.       end
  205.       sprite.z = self.z + 300 + i
  206.       sprite.ox = 96
  207.       sprite.oy = 96
  208.       sprite.zoom_x = cell_data[i, 3] / 100.0
  209.       sprite.zoom_y = cell_data[i, 3] / 100.0
  210.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  211.       sprite.blend_type = cell_data[i, 7]
  212.     end
  213.     #诡异之猫的地图动画显示修正(PART1) 结束
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● SE 与闪烁时间处理
  217.   #     timing : 时间数据 (RPG::Animation::Timing)
  218.   #--------------------------------------------------------------------------
  219.   def animation_process_timing(timing)
  220.     timing.se.play
  221.     case timing.flash_scope
  222.     when 1
  223.       self.flash(timing.flash_color, timing.flash_duration * 4)
  224.     when 2
  225.       if viewport != nil
  226.         viewport.flash(timing.flash_color, timing.flash_duration * 4)
  227.       end
  228.     when 3
  229.       self.flash(nil, timing.flash_duration * 4)
  230.     end
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 诡异之猫的地图动画显示修正(PART2)
  234.   #--------------------------------------------------------------------------
  235.   def x=(x)
  236.     sx = x - self.x
  237.     if sx != 0
  238.       if @animation_sprites != nil
  239.         for i in 0..15
  240.           @animation_sprites[i].x += sx
  241.         end
  242.       end
  243.     end
  244.     super
  245.   end  
  246.   def y=(y)
  247.     sy = y - self.y
  248.     if sy != 0
  249.       if @animation_sprites != nil
  250.         for i in 0..15
  251.           @animation_sprites[i].y += sy
  252.         end
  253.       end
  254.     end
  255.     super
  256.   end
  257. end
复制代码

地图显示动画修正补丁……
系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

名侦探小柯

梦石
0
星屑
3417
在线时间
3628 小时
注册时间
2006-9-6
帖子
37402

开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

4
发表于 2008-8-9 03:04:37 | 只看该作者
那个血条……好面熟啊……

话说不是有官方补丁修复了么……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

很傻很天真

梦石
0
星屑
55
在线时间
3 小时
注册时间
2007-3-13
帖子
3667
5
发表于 2008-8-9 03:12:14 | 只看该作者
以下引用越前リョーマ于2008-8-8 19:04:37的发言:

那个血条……好面熟啊……

话说不是有官方补丁修复了么……

官方修复不彻底……

那个血条当然面熟……
就是你悬赏……
记得是 沉影不器 写的……
不是 沉影 就是柳之一……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
433 小时
注册时间
2007-5-1
帖子
993
6
 楼主| 发表于 2008-8-9 16:10:30 | 只看该作者
感谢LS几位,问题已解决。

话说那个血条是我自己写的说,虽然外观上仿照了夜想曲……

嗯,不能浪费签名了,打广告。本人的悲剧作品:
坑化游戏《龙之影》      R剧《星空》     小游戏《剑与拳头》
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-7-21 03:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表