赞 | 5 |
VIP | 620 |
好人卡 | 38 |
积分 | 69 |
经验 | 125468 |
最后登录 | 2015-7-27 |
在线时间 | 1666 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 6860
- 在线时间
- 1666 小时
- 注册时间
- 2008-10-29
- 帖子
- 6710
|
本帖最后由 后知后觉 于 2010-9-9 16:25 编辑
这次做了两种:
①.和上次那样.最后修改 Scene_Battle 4
- class Game_Battler
- attr_accessor :add_x
- attr_accessor :add_y
- alias hzhj_old_ini initialize
- def initialize
- hzhj_old_ini
- @add_x = 0
- @add_y = 0
- end
- end
- class Sprite_Battler < RPG::Sprite
- MoveSpeed = 8 # X 方向每次移动多少像素
- MoveSpeed_Y = 6 # Y 方向每次移动多少像素
- Jump_SE = RPG::AudioFile.new("016-Jump02", 100, 100)
-
- alias hzhj_old_initialize initialize
- def initialize(*args)
- hzhj_old_initialize(*args)
- if not @battler.nil?
- self.x = @battler.screen_x
- self.y = @battler.screen_y
- self.z = @battler.screen_y
- @hzhj_play_jump = true
- end
- @hzhj_x = self.x
- @hzhj_y = self.y
- end
- def battler=(value)
- if @battler != value and value != nil
- self.x = value.screen_x
- self.y = value.screen_y
- self.z = value.screen_y
- @hzhj_play_jump = true
- end
- @hzhj_x = self.x
- @hzhj_y = self.y
- @battler = value
- end
- alias hzhj_old_update update
- def update
- if not @battler.nil? and not @battler.dead?
- if self.x < @battler.screen_x + @battler.add_x
- self.x = [self.x + MoveSpeed, @battler.screen_x + @battler.add_x].min
- if @hzhj_play_jump
- Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
- @hzhj_play_jump = false
- end
- elsif self.x > @battler.screen_x + @battler.add_x
- self.x = [self.x - MoveSpeed, @battler.screen_x + @battler.add_x].max
- if @hzhj_play_jump
- Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
- @hzhj_play_jump = false
- end
- end
- if self.y < @battler.screen_y + @battler.add_y
- self.y = [self.y + MoveSpeed_Y, @battler.screen_y + @battler.add_y].min
- if @hzhj_play_jump
- Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
- @hzhj_play_jump = false
- end
- elsif self.y > @battler.screen_y + @battler.add_y
- self.y = [self.y - MoveSpeed_Y, @battler.screen_y + @battler.add_y].max
- if @hzhj_play_jump
- Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
- @hzhj_play_jump = false
- end
- end
- if self.x == @battler.screen_x and self.y == @battler.screen_y
- @hzhj_play_jump = true
- # p self.x, @battler.screen_x, self.y, @battler.screen_y
- end
- end
- @hzhj_x = self.x
- @hzhj_y = self.y
- hzhj_old_update
- self.x = @hzhj_x
- self.y = @hzhj_y
- self.z = @hzhj_y
- end
- def x
- if @effect_hzhj
- if @battler.nil?
- return super
- else
- return @battler.screen_x
- end
- else
- return super
- end
- end
- def y
- if @effect_hzhj
- if @battler.nil?
- return super
- else
- return @battler.screen_y
- end
- else
- return super
- end
- end
- def update_animation
- @effect_hzhj = true
- super
- @effect_hzhj = false
- end
- def animation(*args)
- @effect_hzhj = true
- super(*args)
- @effect_hzhj = false
- end
- def update_damage
- @effect_hzhj = true
- super
- @effect_hzhj = false
- end
- def damage(*args)
- @effect_hzhj = true
- super(*args)
- @effect_hzhj = false
- end
- end
- class Scene_Battle
- ACTOR_ADD_X = 64 # X 方向角色一共要移动的像素
- ACTOR_ADD_Y = 48 # Y 方向角色一共要移动的像素
- ENEMY_ADD_X = -64 # X 方向敌人一共要移动的像素
- ENEMY_ADD_Y = -48 # Y 方向敌人一共要移动的像素
- alias hzhj_old_update_phase4_step4 update_phase4_step4
- def update_phase4_step4
- hzhj_old_update_phase4_step4
- for target in @target_battlers
- next if target.dead?
- next if target.damage != "Miss"
- if target.is_a?(Game_Actor)
- target.add_x = ACTOR_ADD_X
- target.add_y = ACTOR_ADD_Y
- elsif target.is_a?(Game_Enemy)
- target.add_x = ENEMY_ADD_X
- target.add_y = ENEMY_ADD_Y
- end
- end
- end
- alias hzhj_old_update_phase4_step5 update_phase4_step5
- def update_phase4_step5
- hzhj_old_update_phase4_step5
- for target in @target_battlers
- target.add_x = 0
- target.add_y = 0
- end
- end
- end
复制代码 ②.修改播放动画的定义.
在数据库做动画的时候.增加一条播放 SE 的命令.
条件设置为 失败.SE 的名字要和脚本里设置的那个一样.
至于是要在第几帧的时候播放.那就要看做的那个动画的需要了.
如果某个动画只要战斗者闪动而不要播放这个声效.
那么还是要设置这条命令.然后把播放的音量设置为最低就可以了.
当这个声效播放的时候.战斗者才开始移动.一般来说.很少有人会在 Sprite_Batttler 重载 RPG::Sprite 的方法 = =b.
兼容性应该还是不错的.我懒得去 alias RPG::Sprite 里的方法了 ^_^ |
评分
-
查看全部评分
|