#============================================================================== # ■ XP-RGSS-38 ダブルアニメーション [Ver.1.1.0] by Claimh #------------------------------------------------------------------------------ # ・アニメーションを二重化します。 #------------------------------------------------------------------------------ # [機能] #・自動合成 #アニメーション名にAとついているアニメーションがあれば自動合成します。 # No.5 : 斬撃A # No.6 : 斬撃AA # ---> No.5のアニメーション表示時にはNo.6のアニメーションも同時に表示 #-< 再定義 >------------------------------------------------------------------- # RPG::Sprite # effect?, x=(), y=() #============================================================================== #============================================================================== # ■ RPG::Sprite #============================================================================== module RPG class Sprite < ::Sprite @@_animations2 = [] @@_reference_count2 = {} # イニシャル処理 alias init_d_anime initialize def initialize(viewport = nil) init_d_anime(viewport) @_animation_duration2 = 0 end # スプライト消去 alias dispose_d_anime dispose def dispose dispose_d_anime dispose_animation2 end # スプライト フレーム更新 alias update_d_anime update def update update_d_anime if @_animation2 != nil and (Graphics.frame_count % 2 == 0) @_animation_duration2 -= 1 update_animation2 end @@_animations2.clear end # エフェクト中? [再定義] def effect? @_whiten_duration > 0 or @_appear_duration > 0 or @_escape_duration > 0 or @_collapse_duration > 0 or @_damage_duration > 0 or @_animation_duration > 0 or @_animation_duration2 > 0 end # スプライトx位置更新 [再定義] def x=(x) sx = x - self.x if sx != 0 if @_animation_sprites != nil for i in 0..15 @_animation_sprites[i].x += sx end end if @_animation_sprites2 != nil for i in 0..15 @_animation_sprites2[i].x += sx end end if @_loop_animation_sprites != nil for i in 0..15 @_loop_animation_sprites[i].x += sx end end end super end # スプライトy位置更新 [再定義] def y=(y) sy = y - self.y if sy != 0 if @_animation_sprites != nil for i in 0..15 @_animation_sprites[i].y += sy end end if @_animation_sprites2 != nil for i in 0..15 @_animation_sprites2[i].y += sy end end if @_loop_animation_sprites != nil for i in 0..15 @_loop_animation_sprites[i].y += sy end end end super end #------------------------------------------------------------------------------- # アニメーション作成 alias d_animation animation def animation(animation, hit) d_animation(animation, hit) if $data_animations[animation.id+1].name.include?("A") animation2($data_animations[animation.id+1], hit) end end #------------------------------------------------------------------------------- # アニメーション作成 [ダブル] def animation2(animation, hit) dispose_animation2 @_animation2 = animation return if @_animation2 == nil @_animation_hit2 = hit @_animation_duration2 = @_animation2.frame_max animation_name = @_animation2.animation_name animation_hue = @_animation2.animation_hue bitmap = RPG::Cache.animation(animation_name, animation_hue) if @@_reference_count2.include?(bitmap) @@_reference_count2[bitmap] += 1 else @@_reference_count2[bitmap] = 1 end @_animation_sprites2 = [] if @_animation2.position != 3 or not @@_animations2.include?(animation) for i in 0..15 sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false @_animation_sprites2.push(sprite) end unless @@_animations2.include?(animation) @@_animations2.push(animation) end end update_animation2 end # アニメーション消去 [ダブル] def dispose_animation2 if @_animation_sprites2 != nil sprite = @_animation_sprites2[0] if sprite != nil @@_reference_count2[sprite.bitmap] -= 1 if @@_reference_count2[sprite.bitmap] == 0 sprite.bitmap.dispose end end for sprite in @_animation_sprites2 sprite.dispose end @_animation_sprites2 = nil @_animation2 = nil end end # アニメーション更新 [ダブル] def update_animation2 if @_animation_duration2 > 0 frame_index = @_animation2.frame_max - @_animation_duration2 cell_data = @_animation2.frames[frame_index].cell_data position = @_animation2.position animation_set_sprites(@_animation_sprites2, cell_data, position) for timing in @_animation2.timings if timing.frame == frame_index animation_process_timing(timing, @_animation_hit2) end end else dispose_animation2 end end end end