#===============================================================================
# Make an enemy trainer slide off-screen from the right. Makes the previous
# trainer slide off to the right first if it is on-screen.
# Used at the end of battle.
#===============================================================================
class TrainerMessageDisappearAnimation < PokeBattle_Animation
def initialize(sprites,viewport,idxTrainer,spriteNameBase)
@idxTrainer = idxTrainer
@spriteNameBase = spriteNameBase
super(sprites,viewport)
end
def createProcesses
delay = 0
if @spriteNameBase=="trainer_"
# Make trainer sprite move off-screen
if @sprites["#{@spriteNameBase}#{@idxTrainer+1}"]
newTrainer = addSprite(@sprites["#{@spriteNameBase}#{@idxTrainer+1}"],PictureOrigin::Bottom)
newTrainer.moveDelta(delay,8,Graphics.width/4,0)
newTrainer.setVisible(delay+8,false)
end
else
if @sprites["#{@spriteNameBase}#{@idxTrainer+1}"]
newTrainer = addSprite(@sprites["#{@spriteNameBase}#{@idxTrainer+1}"],PictureOrigin::Bottom)
newTrainer.moveDelta(delay,8,-Graphics.width/4-64,0)
newTrainer.setVisible(delay+8,false)
end
end
end
end
#===============================================================================
# Make an enemy trainer slide on-screen from the right. Makes the previous
# trainer slide off to the right first if it is on-screen.
# Used at the end of battle.
#===============================================================================
class TrainerMessageAppearAnimation < PokeBattle_Animation
def initialize(sprites,viewport,idxTrainer,spriteNameBase)
@idxTrainer = idxTrainer
@spriteNameBase = spriteNameBase
super(sprites,viewport)
end
def createProcesses
delay = 0
offset = 64
if @spriteNameBase=="trainer_"
# Make old trainer sprite move off-screen first if necessary
if @idxTrainer>0 && @sprites["#{@spriteNameBase}#{@idxTrainer}"].visible
oldTrainer = addSprite(@sprites["#{@spriteNameBase}#{@idxTrainer}"],PictureOrigin::Bottom)
oldTrainer.moveDelta(delay,8,Graphics.width/4,0)
oldTrainer.setVisible(delay+8,false)
delay = oldTrainer.totalDuration
end
# Make new trainer sprite move on-screen
if @sprites["#{@spriteNameBase}#{@idxTrainer+1}"]
trainerX, trainerY = PokeBattle_SceneConstants.pbTrainerPosition(1)
trainerX += 64+Graphics.width/4
newTrainer = addSprite(@sprites["#{@spriteNameBase}#{@idxTrainer+1}"],PictureOrigin::Bottom)
newTrainer.setVisible(delay,true)
newTrainer.setXY(delay,trainerX,trainerY)
newTrainer.moveDelta(delay,8,-Graphics.width/4,0)
end
else
# Make old trainer sprite move off-screen first if necessary
if @idxTrainer>0 && @sprites["#{@spriteNameBase}#{@idxTrainer}"].visible
oldTrainer = addSprite(@sprites["#{@spriteNameBase}#{@idxTrainer}"],PictureOrigin::Bottom)
oldTrainer.moveDelta(delay,8,-Graphics.width/4-offset,0)
oldTrainer.setVisible(delay+8,false)
delay = oldTrainer.totalDuration
end
# Make new trainer sprite move on-screen
if @sprites["#{@spriteNameBase}#{@idxTrainer+1}"]
trainerX, trainerY = PokeBattle_SceneConstants.pbTrainerPosition(1)
newTrainer = addSprite(@sprites["#{@spriteNameBase}#{@idxTrainer+1}"],PictureOrigin::Bottom)
size = newTrainer.src_rect.width # Width per frame
if newTrainer.x!= -96
newTrainer.x = -96
end
newTrainer.setSrc(0,size,0)
newTrainer.setZ(0,100)
newTrainer.setVisible(delay,true)
newTrainer.moveDelta(delay,8,Graphics.width/4+offset,0)
end
end
end
end
class PokeBattle_Scene
#=============================================================================
# Animates an opposing trainer sliding off from off-screen.
#=============================================================================
def pbHideTrainerForMessage(idxTrainer,spriteNameBase)
# Set up trainer appearing animation
disappearAnim = TrainerMessageDisappearAnimation.new(@sprites,@viewport,idxTrainer,spriteNameBase)
@animations.push(disappearAnim)
# Play the animation
while inPartyAnimation?; pbUpdate; end
end
#=============================================================================
# Animates an opposing trainer sliding in from off-screen. Will animate a
# previous trainer that is already on-screen slide off first. Used at the end
# of battle.
#=============================================================================
def pbShowTrainerForMessage(idxTrainer,spriteNameBase)
# Set up trainer appearing animation
appearAnim = TrainerMessageAppearAnimation.new(@sprites,@viewport,idxTrainer,spriteNameBase)
@animations.push(appearAnim)
# Play the animation
while inPartyAnimation?; pbUpdate; end
end
end