Class: Yuki::Animation::Disposable

Inherits:
Object
  • Object
show all
Defined in:
docs/4_Systems_005_Animation.rb

Overview

Disposable animations are animations that behave like normal animation but have few extra features:

  1. Being able to refine the resolver with additional sprites created for the animation
  2. Being able to dispose all the additional sprites when done
  3. Being able to dispose itself when some conditions are met

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(animation, resolver: nil, resolver_refinement: nil, dispose_if_done: true, dispose_criteria: nil) ⇒ Disposable

Create a new disposable animation

Examples:

Animation with map_warp criteria

a = Disposable.new(animation, resolver: { character: $game_player }, resolver_refinement: :character, dispose_criteria: :map_warp)

Animation with character_moved criteria

a = Disposable.new(animation, resolver: { character: $game_player }, resolver_refinement: :character, dispose_criteria: :character_moved)

Animation with tint_changed criteria

a = Disposable.new(animation, resolver: { character: lamp }, resolver_refinement: :character, dispose_criteria: :tint_changed)

Animation with sprite setup

resolver = { viewport: vp, sprites: [[:sp1, Sprite, [], [[:x=, 5]]]] }
a = Disposable.new(animation, resolver: resolver, resolver_refinement: :load_sprites)

Animation with sprite setup and character

resolver = { viewport: vp, sprites: [[:sp1, Sprite, [], [[:x=, 5]]]], character: $game_player }
a = Disposable.new(animation, resolver: resolver, resolver_refinement: :character_and_load_sprites)

Parameters:

  • animation (AnimationMixin) —

    animation to run when everything is refined

  • resolver (Hash) (defaults to: nil) —

    input resolver

  • resolver_refinement (Symbol | Proc) (defaults to: nil) —

    if proc given, the proc argument is the resolver

  • dispose_if_done (Boolean) (defaults to: true)
  • dispose_criteria (Symbol | Proc) (defaults to: nil) —

    if proc given, the proc argument is this Animation::Disposable instance



1239
1240
# File 'docs/4_Systems_005_Animation.rb', line 1239

def initialize(animation, resolver: nil, resolver_refinement: nil, dispose_if_done: true, dispose_criteria: nil)
end

Instance Attribute Details

#animation ⇒ AnimationMixin (readonly)

Returns:



1218
1219
1220
# File 'docs/4_Systems_005_Animation.rb', line 1218

def animation
  @animation
end

#dispose_if_done ⇒ Boolean

Returns:

  • (Boolean)


1220
1221
1222
# File 'docs/4_Systems_005_Animation.rb', line 1220

def dispose_if_done
  @dispose_if_done
end

#resolver ⇒ Hash | nil (readonly)

Returns:

  • (Hash | nil)


1214
1215
1216
# File 'docs/4_Systems_005_Animation.rb', line 1214

def resolver
  @resolver
end

#resolver_input ⇒ Hash | nil (readonly)

Returns:

  • (Hash | nil)


1216
1217
1218
# File 'docs/4_Systems_005_Animation.rb', line 1216

def resolver_input
  @resolver_input
end

Instance Method Details

#dispose

Dispose the animation and all associated resources



1248
1249
# File 'docs/4_Systems_005_Animation.rb', line 1248

def dispose
end

#disposed? ⇒ Boolean

Returns:

  • (Boolean)


1242
1243
# File 'docs/4_Systems_005_Animation.rb', line 1242

def disposed?
end

#done? ⇒ Boolean

Returns:

  • (Boolean)


1245
1246
# File 'docs/4_Systems_005_Animation.rb', line 1245

def done?
end

#start(begin_offset = 0) ⇒ self

Start the animation (initialize it)

Parameters:

  • begin_offset (Float) (defaults to: 0) —

    offset that prevents the animation from starting before now + begin_offset seconds

Returns:

  • (self)


1256
1257
# File 'docs/4_Systems_005_Animation.rb', line 1256

def start(begin_offset = 0)
end

#update

Update the animation



1251
1252
# File 'docs/4_Systems_005_Animation.rb', line 1251

def update
end