Class: NuriYuri::DynamicLight::ScalableDLS

Inherits:
DynamicLightSprite show all
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

#light_id

Attributes inherited from LiteRGSS::ShaderedSprite

#blendmode, #shader

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

Methods inherited from DynamicLightSprite

#dispose, #visible=

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

#dispose, #disposed?

Constructor Details

#initialize(character, light_type, animation_type = 0, zoom_count = 0, opacity_count = 0, init_scale = 1) ⇒ ScalableDLS

Create a new ScalableDynamicLightSprite

Parameters:

  • character (Game_Character)
  • light_type (Integer)

    Type of the light we'll display on the character

  • animation_type (Integer) (defaults to: 0)

    Type of the animation performed on the light

  • zoom_count (Integer) (defaults to: 0)

    initial value of the zoom_count

  • opacity_count (Integer) (defaults to: 0)

    initial value of the opacity_count

  • init_scale (Numeric) (defaults to: 1)

    initial scale of the object



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

#scaleNumeric

Retrieve the current scale of the sprite (without the animation effect)

Returns:

  • (Numeric)


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

Parameters:

  • target_scale (Numeric)

    target value the sprite should scale

  • duration (Integer) (defaults to: 0)

    number of frame the sprite should take 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

Parameters:

  • value (Numeric)

    New zoom



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