Class: Battle::Visual::Transition::Base

Inherits:
Object
  • Object
show all
Defined in:
scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb

Overview

Base class of all transitions

Direct Known Subclasses

Gen6Trainer, RBYTrainer, RBYWild

Instance Method Summary collapse

Constructor Details

#initialize(scene, screenshot) ⇒ Base

Create a new transition

Parameters:



10
11
12
13
14
15
16
17
18
19
# File 'scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb', line 10

def initialize(scene, screenshot)
  @scene = scene
  @visual = scene.visual
  @viewport = @visual.viewport
  @screenshot = screenshot
  # @type [Array<Yuki::Animation>]
  @animations = []
  # @type [Array<Texture, Sprite>]
  @to_dispose = [screenshot]
end

Instance Method Details

#dispose

Dispose the transition (safely clean all things that needs to be disposed)



33
34
35
36
37
# File 'scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb', line 33

def dispose
  @to_dispose.each do |disposable|
    disposable.dispose unless disposable.disposed?
  end
end

#done?Boolean

Tell if the transition is done

Returns:

  • (Boolean)


28
29
30
# File 'scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb', line 28

def done?
  return @animations.all?(&:done?)
end

#pre_transition

Start the pre transition (fade in)

  • Initialize *all* the sprites

  • Create all the pre-transition animations

  • Force Graphics transition if needed.



44
45
46
47
48
49
50
51
52
# File 'scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb', line 44

def pre_transition
  create_all_sprites
  @animations.clear
  transition = create_pre_transition_animation
  transition.play_before(Yuki::Animation.send_command_to(@visual, :unlock))
  @animations << transition
  Graphics.transition(1) # Force graphics to be unfrozen
  @animations.each(&:start)
end

#start_actor_send_animation

Function that starts the Actor send animation



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb', line 95

def start_actor_send_animation
  log_debug('start_actor_send_animation')
  ya = Yuki::Animation
  animation = create_player_send_animation
  # Add message display in parallel
  animation.parallel_add(
    ya.message_locked_animation.play_before(ya.send_command_to(self, :show_player_send_message))
  )
  # Once everything is done, unlock everything
  animation.play_before(ya.send_command_to(@visual, :unlock))
           .play_before(ya.send_command_to(self, :dispose))
  animation.start
  @animations << animation
end

#start_enemy_send_animation

Function that starts the Enemy send animation



81
82
83
84
85
86
87
88
89
90
91
92
# File 'scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb', line 81

def start_enemy_send_animation
  log_debug('start_enemy_send_animation')
  ya = Yuki::Animation
  animation = create_enemy_send_animation
  # Add message display in parallel
  animation.parallel_add(ya.send_command_to(self, :show_enemy_send_message))
  animation.play_before(ya.message_locked_animation)
  # Once everything is done, start the actor sending Pokemon animation
  animation.play_before(ya.send_command_to(self, :start_actor_send_animation))
  animation.start
  @animations << animation
end

#transition

Start the transition (fade out)

  • Create all the transition animation

  • Add all the message to the animation

  • Add the send enemy Pokemon animation

  • Add the send actor Pokemon animation



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb', line 60

def transition
  @animations.clear
  @scene.message_window.visible = true
  @scene.message_window.blocking = true
  @scene.message_window.stay_visible = true
  @scene.message_window.wait_input = true
  ya = Yuki::Animation
  main = create_fade_out_animation
  main.play_before(create_sprite_move_animation)
  @animations << main
  @animations << create_background_animation
  @animations << create_paralax_animation
  # Appearing section
  main.play_before(ya.message_locked_animation)
      .play_before(ya.send_command_to(self, :show_appearing_message))
      .play_before(ya.send_command_to(@scene.visual, :show_team_info))
      .play_before(ya.send_command_to(self, :start_enemy_send_animation))
  @animations.each(&:start)
end

#update

Update the transition



22
23
24
# File 'scripts/01600 Alpha 25 Battle Engine/00002 Battle_Visual/00002 Transition/00000 Transition.rb', line 22

def update
  @animations.each(&:update)
end