Project1
标题:
战斗图位置移动
[打印本页]
作者:
沉默是惊
时间:
2013-8-14 10:18
标题:
战斗图位置移动
本帖最后由 沉默是惊 于 2013-8-18 16:33 编辑
来个大侠看下如何给下面的脚本加上Y坐标的移动
class Game_Battler
attr_accessor :add_x
alias hzhj_old_ini initialize
def initialize
hzhj_old_ini
@add_x = 0
end
end
class Sprite_Battler < RPG::Sprite
MoveSpeed = 8
alias hzhj_old_initialize initialize
def initialize(viewport, battler = nil)
hzhj_old_initialize(viewport, battler)
if not @battler.nil?
self.x = @battler.screen_x
end
@hzhj_x = self.x
end
def battler=(value)
if [url=home.php?mod=space&uid=133701]@battler[/url] != value and value != nil
self.x = value.screen_x
end
@hzhj_x = self.x
[url=home.php?mod=space&uid=133701]@battler[/url] = value
end
alias hzhj_old_update update
def update
hzhj_old_update
self.x = @hzhj_x
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
elsif self.x > @battler.screen_x + @battler.add_x
self.x = [self.x - MoveSpeed, @battler.screen_x + @battler.add_x].max
end
end
@hzhj_x = self.x
end
def x
if @effect_hzhj
if @battler.nil?
return super
else
return @battler.screen_x
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
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 = 10
elsif target.is_a?(Game_Enemy)
target.add_x = -10
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
end
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1