Class: ExampleApp::Pixie
- Inherits:
-
Zif::Sprite
- Object
- Zif::Sprite
- ExampleApp::Pixie
- Defined in:
- app/pixie.rb
Overview
This is the little spinning square which follows the Avatar on the World scene.
Constant Summary
Constants inherited from Zif::Sprite
Instance Attribute Summary
Attributes inherited from Zif::Sprite
#a, #angle, #b, #g, #h, #logical_x, #logical_y, #name, #path, #r, #render_target, #source_h, #source_w, #source_x, #source_y, #w, #x, #y, #z_index
Attributes included from Zif::Clickable
#on_mouse_changed, #on_mouse_down, #on_mouse_up
Attributes included from Zif::Actions::Animatable
#animation_sequences, #cur_animation
Attributes included from Zif::Actions::Actionable
Instance Method Summary collapse
- #float_to(obj) ⇒ Object
-
#initialize ⇒ Pixie
constructor
A new instance of Pixie.
- #random_duration ⇒ Object
- #randomize_color ⇒ Object
- #spin ⇒ Object
Methods inherited from Zif::Sprite
#blend, #blend=, #center, #center_x, #center_y, #clicked?, #color, #color=, #dup_and_assign, #exclude_from_serialize, #hide, #rect, rect_array_to_hash, rect_array_to_source_hash, #rect_hash, rect_hash_to_source_hash, #show, #source_as_rect_hash, #source_center, #source_is_set?, #source_rect, #source_rect_hash, #source_wh, #source_xy, #to_h, #view_actual_size!, #wh, #xy, #zoom_factor
Methods included from Zif::Clickable
Methods included from Zif::Actions::Animatable
#new_basic_animation, #new_tiled_animation, #register_animation_sequence, #run_animation_sequence, #stop_animating
Methods included from Zif::Actions::Actionable
#bounce_forever_around, #delayed_action, #fade_in, #fade_out, #fade_out_and_in_forever, #new_action, #perform_actions, #run_action, #running_actions?, #stop_action
Methods included from Zif::Serializable
#exclude_from_serialize, #inspect, #serialize, #to_s
Methods included from Zif::Assignable
Constructor Details
#initialize ⇒ Pixie
Returns a new instance of Pixie.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/pixie.rb', line 4 def initialize super @w = 10 @h = 10 @source_x = 0 @source_y = 0 @source_w = 10 @source_h = 10 @a = 255 randomize_color @path = 'sprites/white_1.png' end |
Instance Method Details
#float_to(obj) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/pixie.rb', line 35 def float_to(obj) run_action( new_action( {x: :center_x, y: :center_y}, follow: obj, duration: random_duration, easing: :linear ) do # Repeat with new durations and color. @x = 1659 @y = 1659 randomize_color @spin_action.duration = random_duration float_to(obj) end ) end |
#random_duration ⇒ Object
17 18 19 |
# File 'app/pixie.rb', line 17 def random_duration 30 + rand(90) end |
#randomize_color ⇒ Object
21 22 23 |
# File 'app/pixie.rb', line 21 def randomize_color @r, @g, @b = Zif.rand_rgb(100, 255) end |
#spin ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/pixie.rb', line 25 def spin @spin_action = new_action( {angle: 359}, duration: random_duration, easing: :linear, repeat: :forever ) run_action(@spin_action) end |