Module: Yuki::Animation

Defined in:
docs/4_Systems_005_Animation.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

{SMOOTH_DISTORTION: proc { |x| 1 - Math.cos(pi_div2 * x ** 1.5) ** 5 }, UNICITY_DISTORTION: proc { |x| x }, SQUARE010_DISTORTION: proc { |x| 1 - (x * 2 - 1) ** 2 }, SIN: proc { |x| Math.sin(2 * Math::PI * x) }}
TIME_SOURCES =

Hash describing all the time sources

{GENERIC_TIME_SOURCE: Graphics.method(:current_time)}
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



389
390
# File 'docs/4_Systems_005_Animation.rb', line 389

def bgm_play(filename, volume = 100, pitch = 100)
end

.bgm_stop

Stop the bgm



392
393
# File 'docs/4_Systems_005_Animation.rb', line 392

def bgm_stop
end

.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



398
399
# File 'docs/4_Systems_005_Animation.rb', line 398

def bgs_play(filename, volume = 100, pitch = 100)
end

.bgs_stop

Stop the bgs



401
402
# File 'docs/4_Systems_005_Animation.rb', line 401

def bgs_stop
end

.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



272
273
# File 'docs/4_Systems_005_Animation.rb', line 272

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

.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



283
284
# File 'docs/4_Systems_005_Animation.rb', line 283

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

.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



437
438
# File 'docs/4_Systems_005_Animation.rb', line 437

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

.dispose_sprite(name)

Dispose a sprite

Parameters:

  • name (Symbol)

    name of the sprite in the resolver



466
467
# File 'docs/4_Systems_005_Animation.rb', line 466

def dispose_sprite(name)
end

.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



407
408
# File 'docs/4_Systems_005_Animation.rb', line 407

def me_play(filename, volume = 100, pitch = 100)
end

.message_locked_animation

Function that creates a message locked animation



525
526
# File 'docs/4_Systems_005_Animation.rb', line 525

def message_locked_animation
end

.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



212
213
# File 'docs/4_Systems_005_Animation.rb', line 212

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

.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



224
225
# File 'docs/4_Systems_005_Animation.rb', line 224

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

.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:



575
576
# File 'docs/4_Systems_005_Animation.rb', line 575

def move_sprite_position(time_to_process, on, a, b, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)
end

.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



142
143
# File 'docs/4_Systems_005_Animation.rb', line 142

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

.resolvedFullyResolvedAnimation

Create a fully resolved animation



618
619
# File 'docs/4_Systems_005_Animation.rb', line 618

def resolved
end

.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



132
133
# File 'docs/4_Systems_005_Animation.rb', line 132

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

.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>)


489
490
# File 'docs/4_Systems_005_Animation.rb', line 489

def run_commands_during(duration, *animation_commands)
end

.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



153
154
# File 'docs/4_Systems_005_Animation.rb', line 153

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

.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



200
201
# File 'docs/4_Systems_005_Animation.rb', line 200

def scalar_offset(time_to_process, on, property_get, property_set, a, b, distortion: :UNICITY_DISTORTION, time_source: :GENERIC_TIME_SOURCE)
end

.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



413
414
# File 'docs/4_Systems_005_Animation.rb', line 413

def se_play(filename, volume = 100, pitch = 100)
end

.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



462
463
# File 'docs/4_Systems_005_Animation.rb', line 462

def send_command_to(name, command, *args)
end

.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



236
237
# File 'docs/4_Systems_005_Animation.rb', line 236

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

.timed_loop_animation(time_to_process, distortion = :UNICITY_DISTORTION, time_source = :GENERIC_TIME_SOURCE)

Create a new TimedLoopAnimation 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

  • 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



582
583
# File 'docs/4_Systems_005_Animation.rb', line 582

def timed_loop_animation(time_to_process, distortion = :UNICITY_DISTORTION, time_source = :GENERIC_TIME_SOURCE)
end

.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



15
16
# File 'docs/4_Systems_005_Animation.rb', line 15

def wait(during, time_source: :GENERIC_TIME_SOURCE)
end

.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:



648
649
# File 'docs/4_Systems_005_Animation.rb', line 648

def wait_signal(name = nil, *args, &block)
end