Class: Metro::FadeTransitionScene
Constant Summary
Constants included
from Units
Units::Bounds
Instance Attribute Summary
#next_scene, #options, #previous_scene
Attributes inherited from Scene
#window
Instance Method Summary
collapse
#prepare_transition_from, #prepare_transition_to
Methods inherited from Scene
#_prepare_transition, #actor, #add_actors_to_scene, #after, after, #after_initialize, after_intervals, #base_draw, #base_update, #draw, #drawers, #enqueue, hierarchy, inherited, #initialize, metro_name, #notification, #prepare_transition_from, #prepare_transition_to, #register_actor, #register_actors!, #register_after_intervals!, #register_animations!, #register_events!, #register_events_for_target, scene_name, #scene_name, scenes, #state, #to_hash, #to_s, #transition_to, #update, #updaters
Methods included from SceneView
included, #save_view, #view, #view_content, #view_name
#animate, included
Methods included from HasEvents
included
Methods included from Draws
included
Constructor Details
This class inherits a constructor from Metro::Scene
Instance Method Details
#color_from_options(position) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 57
def color_from_options(position)
if options[position]
if options[position][:color]
Gosu::Color.new options[position][:color]
end
end
end
|
#default_final_color ⇒ Object
53
54
55
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 53
def default_final_color
Gosu::Color.new "rgb(0,0,0)"
end
|
#default_interval ⇒ Object
29
30
31
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 29
def default_interval
60
end
|
#default_starting_color ⇒ Object
41
42
43
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 41
def default_starting_color
Gosu::Color.new "rgb(255,255,255)"
end
|
#final_color ⇒ Object
45
46
47
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 45
def final_color
options_final_color || default_final_color
end
|
#interval ⇒ Object
25
26
27
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 25
def interval
options[:interval] || default_interval
end
|
#options_final_color ⇒ Object
49
50
51
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 49
def options_final_color
color_from_options(:to)
end
|
#options_starting_color ⇒ Object
37
38
39
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 37
def options_starting_color
color_from_options(:from)
end
|
#show ⇒ Object
When the scene is shown set up the starting color for the rectangle and queue the animation to transition the color to the final color.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 10
def show
rectangle.color = starting_color
color = final_color
animate :rectangle, to: { red: color.red,
green: color.green,
blue: color.blue,
alpha: color.alpha },
interval: interval do
transition_to next_scene
end
end
|
#starting_color ⇒ Object
33
34
35
|
# File 'lib/metro/transitions/fade_transition_scene.rb', line 33
def starting_color
options_starting_color || default_starting_color
end
|