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

Project1

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

[已经解决] 继续提问MISS时战斗图移位的问题

[复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-7-26
帖子
486
跳转到指定楼层
1
发表于 2010-9-9 12:40:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽

Lv4.逐梦者

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

贵宾

2
发表于 2010-9-9 16:05:55 | 只看该作者
本帖最后由 后知后觉 于 2010-9-9 16:25 编辑

这次做了两种:
①.和上次那样.最后修改 Scene_Battle 4

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

  11. class Sprite_Battler < RPG::Sprite
  12.   MoveSpeed = 8    # X 方向每次移动多少像素
  13.   MoveSpeed_Y = 6  # Y 方向每次移动多少像素
  14.   Jump_SE = RPG::AudioFile.new("016-Jump02", 100, 100)
  15.   
  16.   alias hzhj_old_initialize initialize
  17.   def initialize(*args)
  18.     hzhj_old_initialize(*args)
  19.     if not @battler.nil?
  20.       self.x = @battler.screen_x
  21.       self.y = @battler.screen_y
  22.       self.z = @battler.screen_y
  23.       @hzhj_play_jump = true
  24.     end
  25.     @hzhj_x = self.x
  26.     @hzhj_y = self.y
  27.   end
  28.   def battler=(value)
  29.     if @battler != value and value != nil
  30.       self.x = value.screen_x
  31.       self.y = value.screen_y
  32.       self.z = value.screen_y
  33.       @hzhj_play_jump = true
  34.     end
  35.     @hzhj_x = self.x
  36.     @hzhj_y = self.y
  37.     @battler = value
  38.   end
  39.   alias hzhj_old_update update
  40.   def update
  41.     if not @battler.nil? and not @battler.dead?
  42.       if self.x < @battler.screen_x + @battler.add_x
  43.         self.x = [self.x + MoveSpeed, @battler.screen_x + @battler.add_x].min
  44.         if @hzhj_play_jump
  45.           Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
  46.           @hzhj_play_jump = false
  47.         end
  48.       elsif self.x > @battler.screen_x + @battler.add_x
  49.         self.x = [self.x - MoveSpeed, @battler.screen_x + @battler.add_x].max
  50.         if @hzhj_play_jump
  51.           Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
  52.           @hzhj_play_jump = false
  53.         end
  54.       end
  55.       if self.y < @battler.screen_y + @battler.add_y
  56.         self.y = [self.y + MoveSpeed_Y, @battler.screen_y + @battler.add_y].min
  57.         if @hzhj_play_jump
  58.           Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
  59.           @hzhj_play_jump = false
  60.         end
  61.       elsif self.y > @battler.screen_y + @battler.add_y
  62.         self.y = [self.y - MoveSpeed_Y, @battler.screen_y + @battler.add_y].max
  63.         if @hzhj_play_jump
  64.           Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
  65.           @hzhj_play_jump = false
  66.         end
  67.       end
  68.       if self.x == @battler.screen_x and self.y == @battler.screen_y
  69.         @hzhj_play_jump = true
  70. #        p self.x, @battler.screen_x, self.y, @battler.screen_y
  71.       end
  72.     end
  73.     @hzhj_x = self.x
  74.     @hzhj_y = self.y
  75.     hzhj_old_update
  76.     self.x = @hzhj_x
  77.     self.y = @hzhj_y
  78.     self.z = @hzhj_y
  79.   end
  80.   def x
  81.     if @effect_hzhj
  82.       if @battler.nil?
  83.         return super
  84.       else
  85.         return @battler.screen_x
  86.       end
  87.     else
  88.       return super
  89.     end
  90.   end
  91.   def y
  92.     if @effect_hzhj
  93.       if @battler.nil?
  94.         return super
  95.       else
  96.         return @battler.screen_y
  97.       end
  98.     else
  99.       return super
  100.     end
  101.   end
  102.   def update_animation
  103.     @effect_hzhj = true
  104.     super
  105.     @effect_hzhj = false
  106.   end
  107.   def animation(*args)
  108.     @effect_hzhj = true
  109.     super(*args)
  110.     @effect_hzhj = false
  111.   end
  112.   def update_damage
  113.     @effect_hzhj = true
  114.     super
  115.     @effect_hzhj = false
  116.   end
  117.   def damage(*args)
  118.     @effect_hzhj = true
  119.     super(*args)
  120.     @effect_hzhj = false
  121.   end
  122. end

  123. class Scene_Battle
  124.   ACTOR_ADD_X = 64      # X 方向角色一共要移动的像素
  125.   ACTOR_ADD_Y = 48      # Y 方向角色一共要移动的像素
  126.   ENEMY_ADD_X = -64       # X 方向敌人一共要移动的像素
  127.   ENEMY_ADD_Y = -48       # Y 方向敌人一共要移动的像素
  128.   alias hzhj_old_update_phase4_step4 update_phase4_step4
  129.   def update_phase4_step4
  130.     hzhj_old_update_phase4_step4
  131.     for target in @target_battlers
  132.       next if target.dead?
  133.       next if target.damage != "Miss"
  134.       if target.is_a?(Game_Actor)
  135.         target.add_x = ACTOR_ADD_X
  136.         target.add_y = ACTOR_ADD_Y
  137.       elsif target.is_a?(Game_Enemy)
  138.         target.add_x = ENEMY_ADD_X
  139.         target.add_y = ENEMY_ADD_Y
  140.       end
  141.     end
  142.   end
  143.   alias hzhj_old_update_phase4_step5 update_phase4_step5
  144.   def update_phase4_step5
  145.     hzhj_old_update_phase4_step5
  146.     for target in @target_battlers
  147.       target.add_x = 0
  148.       target.add_y = 0
  149.     end
  150.   end
  151. end
复制代码
②.修改播放动画的定义.
在数据库做动画的时候.增加一条播放 SE 的命令.
条件设置为 失败.SE 的名字要和脚本里设置的那个一样.
至于是要在第几帧的时候播放.那就要看做的那个动画的需要了.
如果某个动画只要战斗者闪动而不要播放这个声效.
那么还是要设置这条命令.然后把播放的音量设置为最低就可以了.
当这个声效播放的时候.战斗者才开始移动.

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

  11. class Sprite_Battler < RPG::Sprite
  12.   MoveSpeed = 8    # X 方向每次移动多少像素
  13.   MoveSpeed_Y = 6  # Y 方向每次移动多少像素
  14.   MISS_SE_NAME = "016-Jump02"   # 播放 SE。如果不想播放的话就把音量设置为 0
  15.                                 # 但是一定要设置一个文件夹内有的音频的文件名
  16.   ACTOR_ADD_X = 64      # X 方向角色一共要移动的像素
  17.   ACTOR_ADD_Y = 48      # Y 方向角色一共要移动的像素
  18.   ENEMY_ADD_X = -64       # X 方向敌人一共要移动的像素
  19.   ENEMY_ADD_Y = -48       # Y 方向敌人一共要移动的像素
  20.   
  21.   alias hzhj_old_initialize initialize
  22.   def initialize(*args)
  23.     hzhj_old_initialize(*args)
  24.     if not @battler.nil?
  25.       self.x = @battler.screen_x
  26.       self.y = @battler.screen_y
  27.       self.z = @battler.screen_y
  28.     end
  29.     @hzhj_x = self.x
  30.     @hzhj_y = self.y
  31.   end
  32.   def battler=(value)
  33.     if @battler != value and value != nil
  34.       self.x = value.screen_x
  35.       self.y = value.screen_y
  36.       self.z = value.screen_y
  37.     end
  38.     @hzhj_x = self.x
  39.     @hzhj_y = self.y
  40.     @battler = value
  41.   end
  42.   alias hzhj_old_update update
  43.   def update
  44.     if not @battler.nil? and not @battler.dead?
  45.       if self.x < @battler.screen_x + @battler.add_x
  46.         self.x = [self.x + MoveSpeed, @battler.screen_x + @battler.add_x].min
  47.       elsif self.x > @battler.screen_x + @battler.add_x
  48.         self.x = [self.x - MoveSpeed, @battler.screen_x + @battler.add_x].max
  49.       end
  50.       if self.y < @battler.screen_y + @battler.add_y
  51.         self.y = [self.y + MoveSpeed_Y, @battler.screen_y + @battler.add_y].min
  52.       elsif self.y > @battler.screen_y + @battler.add_y
  53.         self.y = [self.y - MoveSpeed_Y, @battler.screen_y + @battler.add_y].max
  54.       end
  55.     end
  56.     @hzhj_x = self.x
  57.     @hzhj_y = self.y
  58.     hzhj_old_update
  59.     self.x = @hzhj_x
  60.     self.y = @hzhj_y
  61.     self.z = @hzhj_y
  62.   end
  63.   def x
  64.     if @effect_hzhj
  65.       if @battler.nil?
  66.         return super
  67.       else
  68.         return @battler.screen_x
  69.       end
  70.     else
  71.       return super
  72.     end
  73.   end
  74.   def y
  75.     if @effect_hzhj
  76.       if @battler.nil?
  77.         return super
  78.       else
  79.         return @battler.screen_y
  80.       end
  81.     else
  82.       return super
  83.     end
  84.   end
  85.   def update_animation
  86.     @effect_hzhj = true
  87.     super
  88.     @effect_hzhj = false
  89.   end
  90.   def animation(*args)
  91.     @effect_hzhj = true
  92.     super(*args)
  93.     @effect_hzhj = false
  94.   end
  95.   def update_damage
  96.     @effect_hzhj = true
  97.     super
  98.     @effect_hzhj = false
  99.   end
  100.   def damage(*args)
  101.     @effect_hzhj = true
  102.     super(*args)
  103.     @effect_hzhj = false
  104.     if args[0] == "Miss" and $scene.is_a?(Scene_Battle)
  105.       if not @battler.nil? and not @battler.dead?
  106.         @battler.add_x = 0
  107.         @battler.add_y = 0
  108.       end
  109.     end
  110.   end
  111.   def animation_process_timing(*args)
  112.     super(*args)
  113.     if args[0].se.name == MISS_SE_NAME and $scene.is_a?(Scene_Battle)
  114.       if not @battler.nil? and not @battler.dead? and @battler.damage == "Miss"
  115.         if @battler.is_a?(Game_Actor)
  116.           @battler.add_x = ACTOR_ADD_X
  117.           @battler.add_y = ACTOR_ADD_Y
  118.         elsif @battler.is_a?(Game_Enemy)
  119.           @battler.add_x = ENEMY_ADD_X
  120.           @battler.add_y = ENEMY_ADD_Y
  121.         end
  122.       end
  123.     end
  124.   end
  125. end
复制代码
一般来说.很少有人会在 Sprite_Batttler 重载 RPG::Sprite 的方法 = =b.
兼容性应该还是不错的.我懒得去 alias RPG::Sprite 里的方法了 ^_^

评分

参与人数 1星屑 +300 收起 理由
六祈 + 300 认可答案

查看全部评分












你知道得太多了

回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-7-26
帖子
486
3
 楼主| 发表于 2010-9-9 16:14:31 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者

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

贵宾

4
发表于 2010-9-9 16:21:43 | 只看该作者
噢.= =
那几个 大写字母(常量)放错地方了= =b
把 class Sprite_Battler 里面的那4行放到
class Scene_Battle 下面就可以了
或者直接把那些改成数字.











你知道得太多了

回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-7-26
帖子
486
5
 楼主| 发表于 2010-9-9 16:25:27 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者

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

贵宾

6
发表于 2010-9-9 16:29:43 | 只看该作者
其实还有个问题是状态动画我没做.
状态动画要不要留在原地呢?
现在的效果是状态动画跟着人跑...











你知道得太多了

回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-7-26
帖子
486
7
 楼主| 发表于 2010-9-9 17:08:34 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
112 小时
注册时间
2012-3-16
帖子
65
8
发表于 2013-8-17 11:00:04 | 只看该作者
后知后觉 发表于 2010-9-9 16:29
其实还有个问题是状态动画我没做.
状态动画要不要留在原地呢?
现在的效果是状态动画跟着人跑... ...

貌似这个坊真移位里的话会出现移位错误
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-19 16:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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