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

Project1

 找回密码
 注册会员
搜索
查看: 1803|回复: 3

[已经解决] 如何在MISS时稍微移动战斗图?

[复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-7-26
帖子
486
发表于 2010-9-6 16:41:30 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽

Lv4.逐梦者

梦石
0
星屑
6545
在线时间
1666 小时
注册时间
2008-10-29
帖子
6710

贵宾

发表于 2010-9-6 19:43:49 | 显示全部楼层
大概的做了一下...

  1. class Game_Battler
  2.   attr_accessor :add_x
  3.   alias hzhj_old_ini initialize
  4.   def initialize
  5.     hzhj_old_ini
  6.     @add_x = 0
  7.   end
  8. end

  9. class Sprite_Battler < RPG::Sprite
  10.   MoveSpeed = 8
  11.   alias hzhj_old_initialize initialize
  12.   def initialize(viewport, battler = nil)
  13.     hzhj_old_initialize(viewport, battler)
  14.     if not @battler.nil?
  15.       self.x = @battler.screen_x
  16.     end
  17.     @hzhj_x = self.x
  18.   end
  19.   def battler=(value)
  20.     if @battler != value and value != nil
  21.       self.x = value.screen_x
  22.     end
  23.     @hzhj_x = self.x
  24.     @battler = value
  25.   end
  26.   alias hzhj_old_update update
  27.   def update
  28.     hzhj_old_update
  29.     self.x = @hzhj_x
  30.     if not @battler.nil? and not @battler.dead?
  31.       if self.x < @battler.screen_x + @battler.add_x
  32.         self.x = [self.x + MoveSpeed, @battler.screen_x + @battler.add_x].min
  33.       elsif self.x > @battler.screen_x + @battler.add_x
  34.         self.x = [self.x - MoveSpeed, @battler.screen_x + @battler.add_x].max
  35.       end
  36.     end
  37.     @hzhj_x = self.x
  38.   end
  39.   def x
  40.     if @effect_hzhj
  41.       if @battler.nil?
  42.         return super
  43.       else
  44.         return @battler.screen_x
  45.       end
  46.     else
  47.       return super
  48.     end
  49.   end
  50.   def update_animation
  51.     @effect_hzhj = true
  52.     super
  53.     @effect_hzhj = false
  54.   end
  55.   def animation(*args)
  56.     @effect_hzhj = true
  57.     super(*args)
  58.     @effect_hzhj = false
  59.   end
  60.   def update_damage
  61.     @effect_hzhj = true
  62.     super
  63.     @effect_hzhj = false
  64.   end
  65.   def damage(*args)
  66.     @effect_hzhj = true
  67.     super(*args)
  68.     @effect_hzhj = false
  69.   end
  70. end

  71. class Scene_Battle
  72.   alias hzhj_old_update_phase4_step4 update_phase4_step4
  73.   def update_phase4_step4
  74.     hzhj_old_update_phase4_step4
  75.     for target in @target_battlers
  76.       next if target.dead?
  77.       next if target.damage != "Miss"
  78.       if target.is_a?(Game_Actor)
  79.         target.add_x = -64
  80.       elsif target.is_a?(Game_Enemy)
  81.         target.add_x = 64
  82.       end
  83.     end
  84.   end
  85.   alias hzhj_old_update_phase4_step5 update_phase4_step5
  86.   def update_phase4_step5
  87.     hzhj_old_update_phase4_step5
  88.     for target in @target_battlers
  89.       target.add_x = 0
  90.     end
  91.   end
  92. end
复制代码

评分

参与人数 2星屑 +406 收起 理由
六祈 + 400 认可答案
连城究 + 6 非常感谢,先评一些分……虽然很少 ...

查看全部评分












你知道得太多了

回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-7-26
帖子
486
 楼主| 发表于 2010-9-6 20:18:28 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6545
在线时间
1666 小时
注册时间
2008-10-29
帖子
6710

贵宾

发表于 2010-9-6 22:42:28 | 显示全部楼层
嗯的
先给每个战斗者增加了一个 @add_x 的实例变量
然后 给 Sprite_Batttler 的实例对象 增加了一个 @hzhj_x 的实例变量
这个 @hzhj_x 是用来修正 x 坐标的
因为在旧的  update 方法的末尾处有这样的3行
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
这会扰乱 我们增加进去的新的 update 内容
所以就用了这么一个实例变量来修正这个问题.
新增加的刷新内容是一个把图像一步一步移动的过程
所以在 初始化 initialize 的时候要先设置一下 图像的坐标
不然在战斗开始的情况下.
他会在你看得见的情况下从 0,0 这个点慢慢的移动到战斗者的战斗坐标.
那个重定义的  battler=(value) 也是用来解决这个问题.
重定义的 x update_animation animation damage update_damage
这些是来实现你说的 播放动画和显示伤害要在原来的位置

你先自己试试吧.实在不行的话我再帮你写..











你知道得太多了

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 04:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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