127 lines
No EOL
5.6 KiB
Ruby
127 lines
No EOL
5.6 KiB
Ruby
#==============================================================================
|
|
# ■ RGSS3 ピクチャの上にアニメーション・フラッシュ Ver1.00 by 星潟
|
|
#------------------------------------------------------------------------------
|
|
# ピクチャに対してアニメーションやフラッシュを実行できるようにします。
|
|
#==============================================================================
|
|
# イベントコマンドのスクリプトで設定。
|
|
#------------------------------------------------------------------------------
|
|
# animation_on_picture(1,2,true)
|
|
#
|
|
# ピクチャ番号1番にアニメーションID2を実行し、アニメーション終了までウェイト。
|
|
#------------------------------------------------------------------------------
|
|
# animation_on_picture(1,2,false)
|
|
#
|
|
# ピクチャ番号1番にアニメーションID2を実行し、アニメーション中もウェイトしない。
|
|
#------------------------------------------------------------------------------
|
|
# picture_flash(2,100,150,200,175,60,true)
|
|
#
|
|
# ピクチャ番号2番に赤100、緑150、青200、不透明度175のフラッシュを
|
|
# 60フレームかけて実行し、実行中はウェイト。
|
|
#------------------------------------------------------------------------------
|
|
# picture_flash(2,100,150,200,175,60,false)
|
|
#
|
|
# ピクチャ番号2番に赤100、緑150、青200、不透明度175のフラッシュを
|
|
# 60フレームかけて実行し、実行中はウェイトしない。
|
|
#==============================================================================
|
|
class Game_Picture
|
|
attr_accessor :on_picture_animation_id
|
|
attr_accessor :on_picture_animation_wait
|
|
attr_accessor :picture_flash_data
|
|
end
|
|
class Sprite_Picture < Sprite
|
|
#--------------------------------------------------------------------------
|
|
# 解放
|
|
#--------------------------------------------------------------------------
|
|
alias dispose_animation_on_picture dispose
|
|
def dispose
|
|
dispose_animation_on_picture_sprite
|
|
dispose_animation_on_picture
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# アニメーション用スプライトの解放
|
|
#--------------------------------------------------------------------------
|
|
def dispose_animation_on_picture_sprite
|
|
if @animation_on_picture_sprite && !@animation_on_picture_sprite.disposed?
|
|
@animation_on_picture_sprite.dispose
|
|
@animation_on_picture_sprite = nil
|
|
end
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# その他の更新
|
|
#--------------------------------------------------------------------------
|
|
alias update_other_animation_on_picture update_other
|
|
def update_other
|
|
if @picture
|
|
if @picture.on_picture_animation_id
|
|
dispose_animation_on_picture_sprite
|
|
@animation_on_picture_sprite = Sprite_PictureAnimationSlave.new(
|
|
self,@picture.on_picture_animation_id) if $data_animations[@picture.on_picture_animation_id]
|
|
@picture.on_picture_animation_id = nil
|
|
else
|
|
if @animation_on_picture_sprite
|
|
@animation_on_picture_sprite.update
|
|
if @animation_on_picture_sprite.disposed?
|
|
@animation_on_picture_sprite = nil
|
|
@picture.on_picture_animation_wait = nil
|
|
end
|
|
end
|
|
end
|
|
if @picture.picture_flash_data
|
|
a = @picture.picture_flash_data
|
|
flash(Color.new(a[0],a[1],a[2],a[3]),a[4])
|
|
@picture.picture_flash_data = nil
|
|
end
|
|
end
|
|
update_other_animation_on_picture
|
|
end
|
|
end
|
|
class Sprite_PictureAnimationSlave < Sprite_Base
|
|
#--------------------------------------------------------------------------
|
|
# 初期化
|
|
#--------------------------------------------------------------------------
|
|
def initialize(parent_sprite,animation_id)
|
|
super(parent_sprite.viewport)
|
|
@parent_sprite = parent_sprite
|
|
self.x = parent_sprite.x
|
|
self.y = parent_sprite.y
|
|
self.bitmap = parent_sprite.bitmap
|
|
start_animation($data_animations[animation_id])
|
|
self.bitmap = nil
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# 更新
|
|
#--------------------------------------------------------------------------
|
|
def update
|
|
super
|
|
dispose if !animation?
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# フラッシュ
|
|
#--------------------------------------------------------------------------
|
|
def flash(color, duration)
|
|
@parent_sprite.flash(color, duration)
|
|
end
|
|
end
|
|
class Game_Interpreter
|
|
#--------------------------------------------------------------------------
|
|
# ピクチャの上にアニメーション
|
|
#--------------------------------------------------------------------------
|
|
def animation_on_picture(picture_number,animation_id,wait = nil)
|
|
target = screen.pictures[picture_number]
|
|
return unless target
|
|
target.on_picture_animation_id = animation_id
|
|
target.on_picture_animation_wait = wait
|
|
if wait
|
|
Fiber.yield while (target && target.on_picture_animation_wait)
|
|
end
|
|
end
|
|
#--------------------------------------------------------------------------
|
|
# その他の更新
|
|
#--------------------------------------------------------------------------
|
|
def picture_flash(picture_number,red,green,blue,alpha,duration,wait = nil)
|
|
target = screen.pictures[picture_number]
|
|
return unless target
|
|
target.picture_flash_data = [red,green,blue,alpha,duration]
|
|
wait(duration) if wait
|
|
end
|
|
end |