Module: Yuki::Animation

Defined in:
scripts/01100 Yuki/00100 Animation/00100 Animation.rb,
scripts/01100 Yuki/00100 Animation/00103 Handler.rb,
scripts/01100 Yuki/00100 Animation/00101 Commands.rb,
scripts/01100 Yuki/00100 Animation/00105 SignalWaiter.rb,
scripts/01100 Yuki/00100 Animation/00102 MessageLocked.rb,
scripts/01100 Yuki/00100 Animation/00104 MoveAnimationHelper.rb

Overview

Module containing all the animation utility

Defined Under Namespace

Classes: AudioCommand, Command, Dim2Animation, Dim2AnimationDiscreet, DiscreetAnimation, FullyResolvedAnimation, Handler, MessageLocked, MoveSpritePosition, ResolverObjectCommand, ScalarAnimation, ScalarOffsetAnimation, SignalWaiter, SpriteCreationCommand, SpriteSheetAnimation, TimedAnimation, TimedCommands, TimedLoopAnimation

Constant Summary collapse

DISTORTIONS =

Hash describing all the distrotion procs

{
# Proc defining the SMOOTH Time distortion
  SMOOTH_DISTORTION: proc { |x| 1 - Math.cos(pi_div2 * x**1.5)**5 },
# Proc defining the UNICITY Time distortion (no distortion at all)
  UNICITY_DISTORTION: proc { |x| x },
# Proc defining the SQUARE 0 to 1 to 0 distortion
  SQUARE010_DISTORTION: proc { |x| 1 - (x * 2 - 1)**2 }
}
TIME_SOURCES =

Hash describing all the time sources

{
# Generic time source (callable object that gives the current time)
  GENERIC_TIME_SOURCE: Graphics.method(:current_time) # Time.method(:now)
}
DEFAULT_RESOLVER =

Default object resolver (make the game crash)

proc { |x| raise "Couldn't resolve object :#{x}" }

Class Method Summary collapse

Class Method Details

.bgm_play(filename, volume = 100, pitch = 100)

Play a BGM

Parameters:

  • filename (String)

    name of the file inside Audio/BGM

  • volume (Integer) (defaults to: 100)

    volume to play the bgm

  • pitch (Integer) (defaults to: 100)

    pitch used to play the bgm

.bgm_stop

Stop the bgm

.bgs_play(filename, volume = 100, pitch = 100)

Play a BGS

Parameters:

  • filename (String)

    name of the file inside Audio/BGS

  • volume (Integer) (defaults to: 100)

    volume to play the bgs

  • pitch (Integer) (defaults to: 100)

    pitch used to play the bgs

.bgs_stop

Stop the bgs

.cell_x_change(during, on, cell_start, cell_end, width, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)

Create a src_rect.x animation convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • during (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property (please give sprite.src_rect)

  • cell_start (Integer, Symbol)

    start opacity

  • cell_end (Integer, Symbol)

    end opacity

  • width (Integer, Symbol)

    width of the cell

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.cell_y_change(during, on, cell_start, cell_end, width, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)

Create a src_rect.y animation convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • during (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property (please give sprite.src_rect)

  • cell_start (Integer, Symbol)

    start opacity

  • cell_end (Integer, Symbol)

    end opacity

  • width (Integer, Symbol)

    width of the cell

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.create_sprite(viewport, name, type, args = nil, *properties)

Create a new sprite

Parameters:

  • viewport (Symbol)

    viewport to use inside the resolver

  • name (Symbol)

    name of the sprite inside the resolver

  • type (Class)

    class to use in order to create the sprite

  • args (Array) (defaults to: nil)

    argument to send to the sprite in order to create it (sent after viewport)

  • properties (Array<Array>)

    list of properties to call with their values

.dispose_sprite(name)

Dispose a sprite

Parameters:

  • name (Symbol)

    name of the sprite in the resolver

.me_play(filename, volume = 100, pitch = 100)

Play a ME

Parameters:

  • filename (String)

    name of the file inside Audio/ME

  • volume (Integer) (defaults to: 100)

    volume to play the me

  • pitch (Integer) (defaults to: 100)

    pitch used to play the me

.message_locked_animation

Function that creates a message locked animation

.move(during, on, start_x, start_y, end_x, end_y, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)

Create a move animation (from a to b) convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • during (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property

  • start_x (Float, Symbol)

    start x

  • start_y (Float, Symbol)

    start y

  • end_x (Float, Symbol)

    end x

  • end_y (Float, Symbol)

    end y

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.move_discreet(during, on, start_x, start_y, end_x, end_y, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)

Create a move animation (from a to b) with discreet values (Integer) convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • during (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property

  • start_x (Float, Symbol)

    start x

  • start_y (Float, Symbol)

    start y

  • end_x (Float, Symbol)

    end x

  • end_y (Float, Symbol)

    end y

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.move_sprite_position(time_to_process, on, a, b, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE) ⇒ MoveSpritePosition

Create a new ScalarAnimation convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • time_to_process (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property

  • a (Symbol)

    origin sprite position

  • b (Symbol)

    destination sprite position

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

Returns:

.opacity_change(during, on, opacity_start, opacity_end, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)

Create a opacity animation convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • during (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property

  • opacity_start (Float, Symbol)

    start opacity

  • opacity_end (Float, Symbol)

    end opacity

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.resolvedFullyResolvedAnimation

Create a fully resolved animation

.rotation(during, on, angle_start, angle_end, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)

Create a rotation animation convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • during (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property

  • angle_start (Float, Symbol)

    start angle

  • angle_end (Float, Symbol)

    end angle

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.run_commands_during(duration, *animation_commands)

Note:

Never put dispose command inside this command, there's risk that it does not execute

Try to run commands during a specific duration and giving a fair repartition of the duraction for each commands

Parameters:

  • duration (Float)

    number of seconds (with generic time) to process the animation

  • animation_commands (Array<Command>)

.scalar(time_to_process, on, property, a, b, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)

Create a scalar animation convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • time_to_process (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property

  • property (Symbol)

    name of the property to affect (add the = sign in the symbol name)

  • a (Float, Symbol)

    origin position

  • b (Float, Symbol)

    destination position

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.scalar_offset(time_to_process, on, property_get, property_set, a, b, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE) ⇒ ScalarOffsetAnimation

Create a new ScalarOffsetAnimation

.se_play(filename, volume = 100, pitch = 100)

Play a SE

Parameters:

  • filename (String)

    name of the file inside Audio/SE

  • volume (Integer) (defaults to: 100)

    volume to play the se

  • pitch (Integer) (defaults to: 100)

    pitch used to play the se

.send_command_to(name, command, *args)

Send a command to an object in the resolver

Parameters:

  • name (Symbol)

    name of the object in the resolver

  • command (Symbol)

    name of the method to call

  • args (Array)

    arguments to send to the method

.shift(during, on, start_x, start_y, end_x, end_y, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)

Create a origin pixel shift animation (from a to b inside the bitmap) convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • during (Float)

    number of seconds (with generic time) to process the animation

  • on (Object)

    object that will receive the property

  • start_x (Float, Symbol)

    start ox

  • start_y (Float, Symbol)

    start oy

  • end_x (Float, Symbol)

    end ox

  • end_y (Float, Symbol)

    end oy

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION)

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.wait(during, time_source: :GENERIC_TIME_SOURCE)

Create a “wait” animation

Parameters:

  • during (Float)

    number of seconds (with generic time) to process the animation

  • time_source (#call, Symbol) (defaults to: :GENERIC_TIME_SOURCE)

    callable taking no parameter and giving the current time

.wait_signal(name = nil, *args, &block) ⇒ SignalWaiter

Create a new SignalWaiter animation

Parameters:

  • name (Symbol) (defaults to: nil)

    name of the block in resolver to call to know if the signal is there

  • args (Array)

    optional arguments to the block

  • block (Proc)

    if provided, name will be ignored and this block will be used (it prevents this animation from being savable!)

Returns: