Class: NuriYuri::DynamicLight::ScalableDLS
- Inherits:
-
DynamicLightSprite
- Object
- LiteRGSS::Disposable
- LiteRGSS::Drawable
- LiteRGSS::Sprite
- LiteRGSS::ShaderedSprite
- Sprite
- DynamicLightSprite
- NuriYuri::DynamicLight::ScalableDLS
- Defined in:
- scripts/02000 Nuri Yuri/00001 DynamicLight/00004 ScalableDynamicLight.rb
Overview
Sprite that simulate the dynamic light and can be scaled
Constant Summary
Constants inherited from DynamicLightSprite
DynamicLightSprite::DIRECTION_OFFSET, DynamicLightSprite::NORMAL_OFFSET, DynamicLightSprite::TILE_ZOOM
Instance Attribute Summary
Attributes inherited from DynamicLightSprite
Attributes inherited from LiteRGSS::ShaderedSprite
Attributes inherited from LiteRGSS::Sprite
#__index__, #angle, #bitmap, #height, #mirror, #opacity, #ox, #oy, #src_rect, #viewport, #visible, #width, #x, #y, #z, #zoom, #zoom_x, #zoom_y
Instance Method Summary collapse
-
#initialize(character, light_type, animation_type = 0, zoom_count = 0, opacity_count = 0, init_scale = 1) ⇒ ScalableDLS
constructor
Create a new ScalableDynamicLightSprite.
-
#scale ⇒ Numeric
Retrieve the current scale of the sprite (without the animation effect).
-
#scale_to(target_scale, duration = 0)
Tell the sprite to scale.
-
#update
Update the sprite.
-
#zoom=(value)
Change the zoom of the sprite.
Methods inherited from DynamicLightSprite
Methods inherited from Sprite
#load, #mouse_in?, #set_origin_div, #set_rect, #set_rect_div, #set_z, #simple_mouse_in?, #translate_mouse_coords
Methods inherited from LiteRGSS::Sprite
new, #set_origin, #set_position
Methods inherited from LiteRGSS::Disposable
Constructor Details
#initialize(character, light_type, animation_type = 0, zoom_count = 0, opacity_count = 0, init_scale = 1) ⇒ ScalableDLS
Create a new ScalableDynamicLightSprite
12 13 14 15 16 17 18 19 |
# File 'scripts/02000 Nuri Yuri/00001 DynamicLight/00004 ScalableDynamicLight.rb', line 12 def initialize(character, light_type, animation_type = 0, zoom_count = 0, opacity_count = 0, init_scale = 1) super(character, light_type, animation_type, zoom_count, opacity_count) @scale = init_scale @init_scale = init_scale @target_scale = init_scale @target_scale_count = 0 @target_scale_max = 0 end |
Instance Method Details
#scale ⇒ Numeric
Retrieve the current scale of the sprite (without the animation effect)
29 30 31 |
# File 'scripts/02000 Nuri Yuri/00001 DynamicLight/00004 ScalableDynamicLight.rb', line 29 def scale @target_scale end |
#scale_to(target_scale, duration = 0)
Tell the sprite to scale
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'scripts/02000 Nuri Yuri/00001 DynamicLight/00004 ScalableDynamicLight.rb', line 47 def scale_to(target_scale, duration = 0) @target_scale_count = 0 if duration < 1 @init_scale = @scale = @target_scale = target_scale @target_scale_max = 0 else @init_scale = @scale @target_scale = target_scale.to_f @target_scale_max = duration end PFM.game_state.nuri_yuri_dynamic_light[@light_id][:params][5] = target_scale end |
#update
Update the sprite
34 35 36 37 38 39 40 41 42 |
# File 'scripts/02000 Nuri Yuri/00001 DynamicLight/00004 ScalableDynamicLight.rb', line 34 def update if visible if @target_scale_count < @target_scale_max @scale = @init_scale + @target_scale_count * (@target_scale - @init_scale) / @target_scale_max @target_scale_count += 1 end end super end |
#zoom=(value)
Change the zoom of the sprite
23 24 25 |
# File 'scripts/02000 Nuri Yuri/00001 DynamicLight/00004 ScalableDynamicLight.rb', line 23 def zoom=(value) super(@scale == 1 ? value : value * @scale) end |